Posts

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