FileMaker Pro 13 – HTTP POST and HTTP Headers

In FileMaker Pro v13 you can now perform an HTTP POST when importing XML data or using the “Insert from URL” script step. Both HTTP GET and HTTP/S POST are supported – GET and POST are generally the 2 most popular HTTP Request Methods when working with web services.

FileMaker Pro v12 already supported HTTP GET so nothing has changed here – you only need to specify the URL to perform an HTTP GET request. To perform an HTTP POST request you need to specify a URL starting with either:

  • httppost
  • httpspost

You then include a “?” character in the URL to separate the request URL from the POST data. Everything before the first “?” character is the request URL and everything after the first “?” character is the post data. For example to query a web service that converts Fahrenheit to Celsius you would use the following URL:

httppost://www.w3schools.com/webservices/tempconvert.asmx/FahrenheitToCelsius?Fahrenheit=100

FileMaker Pro recognises that you wish to perform an HTTP POST by the use of “httpost” at the beginning of the URL. The URL for the HTTP POST then becomes everything up to the first “?” character:

http://www.w3schools.com/webservices/tempconvert.asmx/FahrenheitToCelsius

and the POST data is everything after the first “?” character:

Fahrenheit=100

We get an XML result like this:

<?xml version=”1.0″ encoding=”utf-8″?><string xmlns=”http://www.w3schools.com/webservices/”>37.7777777777778</string>

which we could easily parse using FileMaker functions to get the actual Celsius value into a FileMaker field (see Demo File link at the bottom).

HTTP Headers

One of the main limitations when performing an HTTP POST is that we are unable to set the HTTP Headers. When working with web services – particular SOAP/XML based web services – you will often be required to set specific headers before sending the HTTP POST data. With FileMaker Pro 13.0v1 the following headers are set automatically and cannot be changed:

User-Agent: FileMaker/13.0

Content-Type: application/x-www-form-urlencoded

Hopefully a future update to FileMaker Pro will allow developers to set the HTTP Headers for each request – in the meantime you will have to continue using of the available FileMaker plugins (such as the BaseElements plug-in)

 

HTTP POST Demo.fmp12

5 replies
  1. Shawn Mower
    Shawn Mower says:

    Thank you Andrew. I was able to get your example to work on my FM13 test software. Do you know if the httppost can be used in a FM webvewier? Also, do you know if you can use httppost to login to websites on their login forms to submit the user name and password? Also, if a web service requires an xml formatted post but not specific headers, can the FM httppost do that?

  2. Andrew Duncan
    Andrew Duncan says:

    FileMaker Pro 13 supports httpost with the “Insert from URL” script step and for specifying the XML and XSL Options when importing data via XML:

    http://www.filemaker.com/13help/en/html/non_toc.46.34.html

    There’s no support for the web viewer unfortunately. You should be able to use the httppost option where there is an HTML form where the method=”post”. I haven’t tried using FileMaker Pro 13 to submit xml data to a web service but can’t see any reason why it shouldn’t work as the xml data is simply the post data in a particular fomat. Let us know how you go.

  3. Mathijs van Beurden
    Mathijs van Beurden says:

    I love the fact they added native POST!

    But I do have a problem…. I am trying to set some basic stuff in our POS system, using the API of this system.

    httppost://127.0.0.1:13010/OpenSession.json?tag=2811w2p0txnfjagc0adjwjwezjmjrpl4&appid=1f518c6dce0a466d8d0f7c95b0717de4?{ “Code”:”1234″, “DeviceName”:”Demo System” }

    See how there is two ? in there… I need it to post everything after the second ? instead of the first…

  4. Andrew Duncan
    Andrew Duncan says:

    Hi Mathijs,

    Unfortunately with the FileMaker Pro v13 HTTP POST feature everything after the first “?” character is sent as POST data in the message body. You might be better of using a plugin like the free BaseElements plugin to perform the HTTP POST as that lets you pass parameters for the URL and POST Data separately. That’s what we use when working with web services and also lets us set headers etc.

    Andrew

Trackbacks & Pingbacks

Comments are closed.