DevCon, DevCon 2019, FileMaker, FileMaker Data API

FileMaker Data API workshop – activity three

In this activity we’re going to work in FileMaker to replicate the queries made in the previous exercise with Postman. This provides an opportunity to interact with the FileMaker Data API in a programming environment I hope you’re familiar with. It may also provide an opportunity to learn about interacting with external APIs in FileMaker if that’s not something you’ve done a lot of.

In this activity

  1. In the session resources folder locate and open the file Remote.fmp12
  2. Replicate each of the requests in the Postman collection
  3. If you get (really) stuck take a peak in the ‘Help me out’ script folder (not all the answers but lots of tips and tricks and scripts which will work 🙂
  4. Build from there to write a script which will upload newly created records in the contact table to your remote file.

The key FileMaker requirement is the Insert from URL script step. Under the hood this is using a library called cURL, so we’ll often need to pass in cURL options to achieve the desired results.

The cURL website lists all of the options available in cURL, though please be aware that not all of them are supported in FileMaker (see this help document for those which are) and there are some specific FileMaker nuances you need to be aware of with regards to binary data.

For example, here are the cURL options which would be used to login to a remote FileMaker Data API. First we set the credentials into a variable $credentials:

Base64Encode ( $$username & ":" & $$password )

Then our options become:

// for debugging ONLY set error reporting on
"--show-error "  &
"--dump-header $$Headers " &

// explicity say we are performing a post
"-X POST " &

// set the textual data
"--data-ascii @$data " &

// set the Contet type header to JSON
"--header Content-Type:application/json " &

// add in the authorization token
"--header \"Authorization: Basic " & GetValue($credentials ; 1) & "\""

The slightly odd setting in the authorization header where we’re getting the first value of the $credentials variable as if it were a list comes about because the FileMaker Base64Encode function tends to leave a carriage return after the encoded string.

If you find you’re running into issues then refer back to what Postman was doing and look to replicate the same thing in terms of structuring and setting data.

And if you get really stuck – take a sneaky peak in the script folder ‘Help Me Out’ where you’ll find working examples of most of the scripts that you need.

< Back to activity twoOn to activity four >

Leave A Comment