Integrating FileMaker With RESTful APIs
By now you’ve probably heard of REST API, but why should you care as a FileMaker developer? Well REST APIs are a universal standard for interacting with other programs and services, so by learning REST you can greatly expand the capabilities of what FileMaker can do, and the services it can interact with. If you’ve ever wanted to integrate FileMaker with Google Maps, Google Calendar, Microsoft SharePoint, or many other great services, you’ll want to learn what RESTful APIs are and how to use them.
REST stands for “REpresentational State Transfer”. Unfortunately, that doesn’t really tell us much. What this means is that REST is a standard for manipulating data in a standardized format that represents the data. The representational part of REST means that the URL or route you use to access or manipulate the data should correspond with the data, so accessing /users should show users, and /posts, should only show posts, and all actions will take place on those URLs. Another thing you’ll hear a lot when talking about REST is CRUD, which stands for Create, Read, Update, and Delete. With these four actions, you can do anything to a system using an easy-to-understand format.
In order to fully work with a REST API you must understand the different types of HTTP methods you can make. GET is the most common method, and happens anytime you browse the web, or type in a specific URL into the address bar and is what you would use for the “read” in CRUD. The rest of the HTTP methods like POST, PUT, and DELETE can only be performed by web forms or built-in functions provided by most libraries. POST is used to submit data to a server and is generally used to add a new record or pass more data than would reasonable to put in a URL. PUT and PATCH are used to update an existing record, and finally DELETE is obviously used to delete a record. Understanding the basic structure and actions of a RESTful API will make working with them so much easier.
Below are the standard routes used when working with a RESTful API.
Integrating with FileMaker
The main way to interact with a RESTful API from FileMaker is using the “Insert from URL” script step. The “Insert from URL” script step is capable of doing GET requests and POST requests. Whenever you insert from a URL that starts with ‘https’ or ‘http’ you are doing a standard GET request. FileMaker has a unique way of handling POST requests, to do one you would start your URL with either ‘httppost’ or ‘httpspost’. One limitation you will probably run into quickly is the inability to set custom HTTP headers before sending a request. This is sometimes necessary for authentication or telling the API what the data format being submitted is. If you run into this your best option is to use the excellent BaseElements Plugin by Goya, which has the capability to set HTTP headers using the BE_HTTP_Set_Custom_Header function, which works with the following functions: BE_HTTP_GET, BE_HTTP_POST, BE_HTTP_PUT_DATA, BE_HTTP_DELETE.
Download the sample file below to look under the hood. In the sample file we have integrated with a simple Ruby on Rails app we spun up that manages usernames; while most services you’ll work with will be more complicated than this, it’s still a great example of how to work with a REST API.
REST is a great addition to any FileMakers developer’s toolkit, allowing FileMaker to integrate with some of the most used services on the web today and we’re only going to see more of it in the future. Because all REST APIs use the same conventions and principles, working with RESTful APIs will only get easier the more you work with them, and there is no time like now to start learning.
Did you know we are an authorized reseller for FileMaker Licensing?
Contact us to discuss upgrading your FileMaker software.
Download Integrating FileMaker With RESTful APIs
Please complete the form on the original Integrating FileMaker with RESTful APIs to download your FREE FileMaker database file.
Originally published on DB Services Integrating FileMaker with RESTful APIs.