FileMaker cURL Options
One of the most important and wide-reaching updates in FileMaker 16 is the ability to set cURL options in the Insert from URL script step. This allows FileMaker to natively integrate with innumerable services across the web, including Google Calendar, Google Maps, Microsoft SharePoint, and many other services.
What is cURL?
cURL stands for ‘Client URL Request Library,’ or just ‘Client for URLs,’ and it’s a way to interact with data across devices around the world with many different protocols, such as HTTP, FTP, etc. FileMaker 16 allows users to specify headers, set request types, receive response codes, among many other things.
HTTP response codes are important because they let you know whether your operation ran correctly or not. If you get a code back that starts with 2, you know it succeeded (e.g. 200). Any other code, it failed (e.g. 404). Checking the response code is a necessity in REST APIs.
FileMaker cURL in Action
Using the Integrating FileMaker with RESTful APIs file, we’ve updated it to now use Insert from URL with cURL options instead of the BaseElements plugin. We can now natively perform all of the HTTP CRUD functions AND get responses and set HTTP headers, which wasn’t possible before FileMaker 16. Because plugins aren’t necessary, that also means that users on FileMaker Go, WebDirect, and even Custom Web Publishing have the same power the desktop app is capable of.
So what does it look like?
FileMaker 16 updated the Insert from URL script step in a couple of different ways. First, they added cURL options that you can specify as a calculation:
Second, they opened up the Target to be either a field or a variable, instead of just a field:
In our GIF above, our cURL options calc looked like this:
Let’s break it down:
- The “-X” means that we have a request. Note that cURL shortcuts are case-sensitive, so “-X” and “-x,” for example, don’t mean the same thing.
- “POST” says what kind of HTTP request it is (create).
- The “-D” means that we want a header dump.
- The “$httpResponseHeaders” variable is where we want the headers dumped to. “–header” means we want to specify a request header.
- “\”Content-type: application/x-www-form-urlencoded\””” says we we’re sending the header as a string.
After running the script, the HTTP status header we got back was:
That’s a lot of text, but the most important part is the first line: code 201 lets us know the record was created. Huzzah!
While this expands the functionality of FileMaker immensely, in taking a look at FileMaker’s supported cURL options, it’s important to note that not all cURL options are available. However, given the importance of cURL and the power it brings, it’s a great start.
FileMaker and cURL go hand-in-hand with allowing FileMaker solutions to natively interact with other platforms and services in ways that greatly improve its depth and scope. It gives all users, whether on desktop, mobile, Custom Web Publishing, or WebDirect, the ability to interact with external services through FileMaker without the need for plugins.
Download FileMaker CURL Options
Please complete the form below to download your FREE FileMaker database file.