GC

Subcontractor

Field Service

Home Builder

Manufacturing

Custom Solutions

 

DocuWrx

844-DOCUWRX

DocuWrx is a premiere FileMaker developer. Our flagship solution, Kosmas, is an end-to-end vertical market solution for the construction industry. DocuWrx also creates first class custom business solutions for many different industries including hospitality, retail, property management, healthcare, manufacturing, and many more. If you are looking for a custom solution for for your business or are interested in Kosmas, inquire below.

Custom Kosmas

Getting to Know the New FileMaker Data API

When FileMaker launched FileMaker 16, they added a new way to access all your FileMaker data with an easy-to-use data format that is the industry standard REST API, FileMaker Data API. By going with a standardized format, developers are able to integrate any platform they choose with FileMaker solutions on FileMaker Server.

Where Can I Find FileMaker’s Documentation About the FileMaker Data API?

When starting out with the FileMaker Data API, you are going to rely heavily on FileMaker’s help document, as it is a complicated process that you will need to familiarize yourself with before navigating on your own. .

Filemaker’s Data API help document can be found at the following link: https://fmhelp.filemaker.com/docs/16/en/restapi/

Is It a Data API or a REST API?

FileMaker’s Data API is both! Its official FileMaker-given name is the FileMaker Data API but it is a REST API. Here’s what that means, “The FileMaker® Data API is an application programming interface (API) that allows web services to access data in hosted solutions. Because this API conforms to Representational State Transfer (REST) architecture, the FileMaker Data API is a REST API.”

What Do I Need?

In order to set up a FileMaker Data API on your own, there are a series of steps. First, you will need FileMaker Server 16 with the FileMaker Data API enabled within the Admin Console.

You can find more information about configuring the Data API on FileMaker Server 16 here: http://www.filemaker.com/help/16/fms/en/#page/fms%2Fconfig_webpub_fmdapi.html%23

FM 16 Data API Blog - What Do I Need

Second, you will need FileMaker Pro 16 or Pro Advanced 16 to create and manage your file.

Third, you will need a file to test with. You will need to have your file hosted on your server, not opened locally, in order to test the Data API. You will also need to give your account’s privilege set the extended privilege fmrest.

There are a number of technologies that are used to communicate with the Data API that you should have an understanding of; including JSON, cURL, HTTP POST, HTTP GET, HTTP PUT and HTTP DELETE. If you aren’t familiar with these yet, familiarizing yourself with FileMaker Data API is actually a great way to learn about these languages.

Shortcomings

Potential Cost Increases

Most developers Coming from the FileMaker API for PHP are very skeptical of the FileMaker Data API. The PHP API has always been free and developers have gotten very used to it. The FileMaker Data API is currently being licensed as a “trial”, with unknown plans to be monetized by FileMaker in the future. This obviously makes it hard to count on the Data API when putting together new projects for clients because, right now, there is no way to tell how much FileMaker will charge for this service or when they will start charging it.

Technical Flaws

There are some technical shortcomings. Right now, there is no way to perform a script using the Data API. There is also no way to transfer container data unless you use Base64Encode and Base64Decode to send the container data as text.

JavaScript API Calls

Another major handicap is that Data API calls work fine from within FileMaker Pro using Insert from URL with cURL, they work fine in Postman (a great application that helps you test HTTP requests and read their responses) but they do not appear to work when the calls come from JavaScript. I was trying to develop an AngularJS site that used the Data API and HTTP requests to show the user data with no PHP involved. It sounded exciting but the Data API rejected my requests.

Advantages

The best part about the FileMaker Data API is how simple it is to set up (as described above). Setting up the PHP API involves hosting PHP files on either your FileMaker server or on a dedicated server (which is what FileMaker recommends you do). If you have a dedicated web server, this would mean paying for additional hardware and spending time to set up, secure, and maintain an extra server.

Implementation

DocuWrx built a FileMaker Go database that was designed to be used offline and synced with a hosted file whenever internet becomes available. The goal of this was to push leads captured at a conference to the appropriate database once the user was back at their hotel, for example.

You can download the demo file of the example from this article using the following link: https://drive.google.com/file/d/10FqCBtMzCqB_fQjRmFQ-CUDWNYh10piw/view?usp=sharing

Getting Connected

In order to access your FileMaker data from the Data API, you must follow a series of steps.

FileMaker 16 Data API

  • Set variable $url to: “https://YourFileMakerServerPath/fmi/rest/api/auth/YourHostedFileMakerFile”
  • Set variable $json to:

                        JSONSetElement (
                        “” ;
[ “user” ;
“The account name to log into your hosted file with.” ;
JSONString ] ;
[ “password” ;
“The password for your account in your hosted file.” ;
JSONString ] ;
[ “layout” ;
“The layout to operate on in your hosted file.” ;
JSONString ]
                        )

  • Set variable $curl to: “-X POST –header ” & Quote ( “Content-Type: application/json” ) & ” -d @$json”
  • Insert from URL. Set Specify URL to $url, set Specify cURL options to $curl and set Target to a variable, $result.

To see if you got an error from the API, set variable $api_error to: JSONGetElement ( $result ; “errorMessage” )

If you didn’t get an error then you connected successfully and got a token. Set variable $your_hosted_file_token to: JSONGetElement ( $result ; “token” )

You will use this variable in every API call you make to this database.

If you need to communicate with more than one database, you will need to go through this authentication process again, using the other file’s connection information, and set a different variable to the result’s token, such as $your_other_hosted_file_token.

Creating a Record

FileMaker 16 Data API

  • Set variable $url to: “https://YourFileMakerServerPath/fmi/rest/api/record/YourHostedFileMakerFile/LayoutWhereYourRecordWillBeCreated”

      Notice that, after the path to YourHostedFileMakerFile, you add the name of the LayoutWhereYourRecordWillBeCreated.

  • Set variable $json_object to:

JSONSetElement (
“” ;
[ “Primary Key” ;
$lead_primary_key ;
JSONString ] ;
[ “First Name” ;
Leads::First Name ;
JSONString ] ;
[ “Last Name” ;
Leads::Last Name ;
JSONString ] ;
[ “Business Card” ;
Base64Encode ( Leads::Business Card ) ;
JSONString ]
)

In this example, we are creating a record in the Leads table and setting the Primary Key, First Name, Last Name and a Container field for their Business Card. We set the Primary Key to $lead_primary_key explicitly so we can use this variable, containing a UUID, to create a related record later on. Notice that I have to use the Base64Encode feature with the Business Card in order to send the container data as text.

  • Set variable $json to:

JSONSetElement (
“” ;
“data” ;
$json_object ;
JSONObject
)

Some developers may have a bit of a hard time with this part. It is not obvious that you have to create a JSONObject for a new record to go inside a JSON element containing the data you want to send to the FileMaker database.

  • Set variable $curl to: “-X POST –header ” & Quote ( “Content-Type: application/json”  ) & ” –header ” & Quote ( “FM-Data-token: ” & $api_token ) & ” -d @$json”

Because you are creating a record, you must include the token of the connected database. After authenticating, FileMaker will post the data in the $json variable to the table of the layout specified in $url.

Insert from URL. Set Specify URL to $url, set Specify cURL options to $curl and set Target to a variable, $result.

To see if you got an error from the API, set variable $api_error to: JSONGetElement ( $result ; “errorMessage” )

Creating a Related Record

FileMaker 16 Data API

  • Set variable $url to: “https://YourFileMakerServerPath/fmi/rest/api/record/YourHostedFileMakerFile/LayoutWhereYourRelatedRecordWillBeCreated”
  • Set variable $json_object to:

JSONSetElement (
“” ;
[ “Lead Foreign Key” ;
$lead_primary_key ;
JSONString ] ;
[ “Email Address” ;
Leads::Email Address ;
JSONString ]
)

Using the same UUID, $lead_primary_key, given to the lead earlier to relate the email record.

  • Set variable $json to:

JSONSetElement (
“” ;
“data” ;
$json_object ;
JSONObject
)

  • Set variable $curl to: “-X POST –header ” & Quote ( “Content-Type: application/json”  ) & ” –header ” & Quote ( “FM-Data-token: ” & $api_token ) & ” -d @$json”
  • Insert from URL. Set Specify URL to $url, set Specify cURL options to $curl and set Target to a variable, $result.

That Wasn’t So Bad, Was It?

Learning the FileMaker Data API can take developers a full 8 hour work day to get familiar with but our development team really enjoyed doing it. Once they got used to it, they almost felt like they could entirely replace their precious PHP API. Once the FileMaker Data API’s shortcomings are addressed,  we could see it becoming the best way to communicate with FileMaker data.

Newsletter

Address

14010 Roosevelt Blvd
14010 Roosevelt Blvd
Suite 710
Suite 710
Clearwater, Florida
Clearwater, Florida
33762
33762

Hours

Monday - Friday
Monday - Friday
9:00 AM - 6:00 PM ET
9:00 AM - 6:00 PM ET