1 2 Previous Next 26 Replies Latest reply on Jun 9, 2017 6:20 AM by fmpdude

    HTTPPost Question

    fmpdude

      I have a FMP INSERT FROM URL I'm trying to POST to a service.

       

      For some reason, the two request variables below, custId and Name, are coming in to the service as part of the request body not as parameters. Thus, I can't snag 'em in the service using standard methods.

       

      Is the syntax below correct for a POST request?

       

      "httppost://localhost:8080/submitCustomer?" & "custId=" & Customer::ID & "&Name=" & Customer::firstName

       

      Not sure why it's not working.

       

      Thanks in advance,

        • 1. Re: HTTPPost Question
          jormond

          Does the request need to be httpspost?

           

          Are you using the "Automatically encode URL" option in Insert from URL?

          1 of 1 people found this helpful
          • 2. Re: HTTPPost Question
            fmpdude

            Joshua Ormond wrote:

             

            Does the request need to be httpspost?

             

            Are you using the "Automatically encode URL" option in Insert from URL?

            (1) httpspost? Nope, just a local connection.

             

            (2) Auto encode? Tried with and without Automatically encode URL.

             

            --------------------------------

            Get this on the service side:

            --------------------------------

            Request IP 0:0:0:0:0:0:0:1

            Request Verb POST

            Request User Agent FileMaker/14.0

            Request Received:custId=234&Name=FredJ

            URL Received:http://localhost:8080/submitCustomer

             

            Also, request.QueryParams() is empty. This should be a set of the parameters POSTed to the service.

             

            Thanks,

            • 3. Re: HTTPPost Question
              sam_oda

              Which FileMaker version do you use? ver16?

              In ver16,

              "Description

              Insert From URL supports http, https, ftp, ftps, and file protocols. FileMaker Pro downloads the resource that is specified by the URL to a variable or a field." (from ver16 Help Document)

              • 4. Re: HTTPPost Question
                fmpdude

                Thanks, Sam, but please check out this link:

                 

                Support for HTTP POST operations in FileMaker Pro | FileMaker

                 

                HTTPPOST has been supported since version 13.

                 

                Thanks,

                • 5. Re: HTTPPost Question
                  jormond

                  Your syntax looks correct. Can you test it in PostMan ( or something similar ) and see if it generates a result?  InsertFromURL ( ) has always felt like a mysterious black box to me. I use it occasionally, but up until now, I usually nee custom headers, which it doesn't do.

                  1 of 1 people found this helpful
                  • 6. Re: HTTPPost Question
                    sam_oda

                    Sorry, fmpdude

                    I misunderstood that 'httppost' is no longer supported.

                    I tested it on my local server, then it works fine.Screen Shot 2017-06-09 at 4.43.14.png

                    Here is my server side log

                    Screen Shot 2017-06-09 at 4.40.13.png

                    1 of 1 people found this helpful
                    • 7. Re: HTTPPost Question
                      wimdecorte

                      fmpdude wrote:

                       

                      I have a FMP INSERT FROM URL I'm trying to POST to a service.

                       

                      For some reason, the two request variables below, custId and Name, are coming in to the service as part of the request body not as parameters.

                       

                      That's the essence of an HTTP POST, that it sends your parameters as key/value pairs in the body (or whatever you specify in the Content-Type header).  With no length restrictions or encoding mess.

                       

                      You'll find plenty of discussions about this on the various big forums, it's a well-debated topic on whether it should be allowed or not and how to force it.

                       

                      IMHO the easiest is to update your receiving web service to deal with the body content.

                      • 8. Re: HTTPPost Question
                        fmpdude

                        I can surely do that since it's a single method and I could just use String methods to extract the parts. But what happens when another client send in the name value pairs as Request parameters? Then I also need code to check what was sent and how (Request body vs. Request parameters).

                         

                        In your experience is it typical for POSTMAN to work as expected (as it did here, thanks to jormond for that suggestion), but not, in, say, FileMaker?

                         

                        IOW, do you think this is just an implementation difference?

                         

                        The last poster said the POST worked fine for him.

                         

                        Since i don't have 16 maybe it's a HTTP header issue?

                         

                        GETs work perfectly.

                         

                        Strange.

                         

                        Thanks Wim.

                        • 9. Re: HTTPPost Question
                          fmpdude

                          What are you using for a server? Port 8000 makes me think REST + Tomcat as I sometimes use that port myself.

                          • 10. Re: HTTPPost Question
                            wimdecorte

                            fmpdude wrote:

                             

                            Since i don't have 16 maybe it's a HTTP header issue?

                             

                             

                            Could be, in 14 you can't specify custom headers.  But if your web service doesn't expect them then you should be good.

                             

                            If you support both GET and POST then you'd have code for the two different routes.  Your web service recognizes the request and routes one to the GET code and the other to the POST code and they each handle the request differently.

                            • 11. Re: HTTPPost Question
                              sam_oda

                              I use Node.js

                              1 of 1 people found this helpful
                              • 12. Re: HTTPPost Question
                                sam_oda

                                fmpdude:

                                I missed the part of your comment

                                 

                                >are coming in to the service as part of the request body not as parameters

                                 

                                As wimdecorte said, it's just the problem to change the server side code.

                                • 13. Re: HTTPPost Question
                                  fmpdude

                                  The same code works fine with POSTMAN.

                                   

                                  In any case, I took your suggestion and have the following code in the web service method:

                                   

                                  if (request.userAgent().toUpperCase().contains("FILEMAKER"))

                                  {

                                    // extract variables from Request body
                                    encodedRegEx = URLDecoder.decode(request.body().substring
                                         (request.body().indexOf("encoded") + 8, request.body().

                                          indexOf("&")),"UTF-8"); // +8 -> offset "encoded="


                                    stringToRegEx = request.body().substring(request.body().

                                          indexOf("&") + 8);  // +8 -> Offset the "&string="
                                  }

                                  else
                                  {

                                    // assume Request variables come in via normal methods.
                                    encodedRegEx = request.queryParams("encoded");

                                    stringToRegEx = request.queryParams("string");

                                  }

                                  .

                                  .

                                  .

                                  Works OK now.

                                   

                                  Moving on...

                                   

                                  Thanks Wim!  (prob looks a lot like some of your C# code I'm guessing...)

                                  1 of 1 people found this helpful
                                  • 14. Re: HTTPPost Question
                                    fmpdude

                                    Yeah, in FMP, for some strange reason, the request variables are coming into the service's Request.body().

                                     

                                    Same URL in POSTMAN, the Request variables come into the service as expected POST parameters.

                                    1 2 Previous Next