When you set out to integrate with an API, you will often find cURL examples in the API’s documentation, like this one from box.com.
These cURL examples are meant to be used in command-line cURL calls (they start by invoking the curl executable as the first word in the syntax), and when you try to use the syntax as-is in FileMaker, it will fail. That is something we wrote about a few years ago. FileMaker uses a cURL library, not the cURL command line.
Translating the provided cURL examples into the components needed to make FileMaker’s Insert From URL script step work is fairly straightforward. To make things even easier, this blog post comes with a utility file that does it for you.
In FileMaker, you need to specify the URL and the cURL options separately. And you need to make sure that your cURL options do not contain any single quote characters (‘). Any regular quotes need to be escaped, of course, which can be a bit of pain.
FileMaker cURL Utility
In the utility, just paste in the cURL syntax that you get from your favorite tool or from the API documentation:
Click the button, and you will get a breakdown of the elements for your Insert From URL script step:
The tool will also separate any data that you are sending and show how you can use a variable and the odd “@$” syntax as a placeholder for the data or file that you are sending. The example above shows a JSON body that is being sent to the API. You would build the $payload variable ahead of time with the FileMaker JSON functions. That way, you never have to go through the trouble of escaping any quotes in the data you are transmitting.
When you are trying to send a file, the tool will alert you to the fact that Claris has deliberately neutered – for security reasons – the cURL library so that it cannot read from a file on the hard drive. You will need to put the file in a container field or variable first and then reference that field or variable in the cURL options syntax.
Moving Forward with FileMaker cURL
If you have any questions about how to translate your auto-generated cURL or would like help further customizing your FileMaker application, our team of consultants may be able to help. Contact us today.