Aller au contenu
  • billets
    74
  • commentaire
    0
  • vues
    4 003

Integrating FileMaker With RESTful APIs

DB Services

186 vues

FileMaker and 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 CalendarMicrosoft SharePoint, or many other great services, you’ll want to learn what RESTful APIs are and how to use them.

REST Overview

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. Go ahead and test the GET commands by clicking on the routes below to view some sample data.

METHOD ROUTE PARAMS ACTION
GET /posts Retrieves a list of all posts.
GET /posts/1 Retrieves post with ID number 1.
GET /posts/1/comments Retrieves all comments from post number 1.
POST /posts

{
“userId”: 1,
“title”: “title”,
“body”: “body…”
}

Adds a new post.
PUT /posts/1

{
“title”: “New Title”
}

Updates post number 1’s title to New Title.
DELETE /posts/1 Deletes post number 1.

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.

Conclusion

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.

DownloadDownload Integrating FileMaker With RESTful APIs

Please complete the form below to download your FREE FileMaker database file.

  • Name*
    First Last
  • Company
  • Phone*
  • Email*
  • Terms of Use
    • I agree
    OPT-IN: I agree that I am downloading a completely free FileMaker application file with no strings attached. This database is unlocked, and I may use it for my business or organization as I see fit. Because I am downloading a free database, I agree that I should receive occasional marketing. I understand that I can OPT-OUT of these emails at anytime.

Afficher la totalité du billet



0 Commentaire


Commentaires recommandés

Il n’y a aucun commentaire à afficher.

Créer un compte ou se connecter pour commenter

Vous devez être membre afin de pouvoir déposer un commentaire

Créer un compte

Créez un compte sur notre communauté. C’est facile !

Créer un nouveau compte

Se connecter

Vous avez déjà un compte ? Connectez-vous ici.

Connectez-vous maintenant

×