Find answers, ask questions, and connect with our community of business solutions and app users, developers, and partners.
This is our featured January Blog from Darren Burgess “Killer Bee” at Beezwax. If you would like to incorporate these features into your FileMaker contact the Beezwax Team!
If you are FileMaker developer, but new to the notion of web APIs and web development in general, then you might take on a kind of deer-in-the-headlights look when confronted with FileMaker Server 16’s new Data API, aka “REST API”. Fear Not! It really is simpler and more straightforward than you might expect. I like to take the attitude that no skill is difficult, only unfamiliar. With study and repetitive exposure and practice, any skill can be mastered.
First, get familiar with REST
Let’s start by getting familiar with REST! First off, I’d like to limit the scope of this post to understanding FileMaker’s implementation of REST, not REST in general. If you need to start from the beginning, I would suggest this tutorial. Frankly, I just chose this from a Google search for “REST API Tutorials”. I would suggest you do the same and review a variety of materials until you get it.
Ok, thanks for coming back. Now that you understand the basics, let’s dig into the particulars of FileMaker’s implementation of a REST API. It is not always readily apparent how to structure the syntax for successful API calls. After quite a bit of fiddling and trial-and-error, I believe I have figured most of it out. So you get to benefit from my suffering. Lucky you!
What does the FileMaker Data API do?
The Data API provides all of the basic CRUD operations (Create, Read, Update, Delete) against your hosted FileMaker data. Note the emphasis on hosted as this is a feature of FileMaker Server and its ability to respond to REST requests for your hosted FileMaker solutions and return a data response in JSON format. This will not work on an un-hosted FileMaker solution.
FileMaker Pro 16 ships with additional cURL options in the Insert from URL script step. This upgrade brings the FileMaker client up-to-date with an ability to interact with REST APIs without the use of a plugin. This is important, because in the sample file available below, we are leveraging the new cURL options to allow a FileMaker solution to talk to its own hosted Data API, giving it the power to interrogate and alter its own data through the API. The sample file is a great way to learn how to work with both the cURL options and the Data API.
So let’s get started. First, download and host the sample file on FileMaker 16 Server. Note that to make the Data API available for a hosted solution, you need to enable such in the privilege sets that require Data API access. In the sample file, I created an account and assigned it to the Data Entry Only privilege and activated the Access via FileMaker Data API extended privilege for Data Entry Only. Note that in production, you should create a custom privilege for Data API access and limit the privileges so that the Data API user account only has access to the solution resources dictated by your requirements.
The REST Layout
Nearly all of the REST calls you will make to a FileMaker solution require that you pass in the name of a specific layout. Placing fields and related data portals on this layout will define the data that you can interact with for all of the CRUD operations. In the sample file, this layout is called rest_layout. Those of you familiar with using the PHP API for FileMaker will understand this concept, as the PHP API also requires a defined layout that provides the data access functionality to the API.
The Sample File
From here on out, I suggest you host the sample file on FileMaker Server 16 and dig in the demos provided there. Make sure you use FileMaker Pro 16 (or 16 Advanced) to access the file. The sample file walks thorough most of the functionality provided by the Data API and clearly illustrates the cURL syntax required to execute Data API calls using the Insert From URL script step.
The sample file (check out the scripts!), plus the documentation for the Data API (provided in the sample file) and cURL options will help you develop an understanding of this new feature of FileMaker Server. Note that the sample file is a learning resource, not an example of robust production-ready code. In the first tab of the sample file you will need to enter server and account information. This is required for the demo to work.
Good luck and please do reach out if you have questions or comments!