AnsweredAssumed Answered

What is an elegant way to set up a REST endpoint - capable of receiving JSON

Question asked by wimmmmm on Sep 20, 2018
Latest reply on Sep 20, 2018 by fmpdude

I trying to get to this construction:

  • some website handles new orders
  • step A: when a new order is created, the website wants to send over a small chunk of data, in JSON format, to announce that a new order is available for the Filemaker db to do further stuff with it
  • step B: after receiving the signal, Filemaker will call an endpoint on the webserver to retrieve all detailed info

 

Step B is completely under control - Insert from URL will fetch the JSON payload (order contains over 40 data elements in various structures). I'll chop it into pieces, create/update various records and sorts.

 

It's step A that I'm still puzzling to get into shape:

  • I downloaded the Postman set offered by Wim Decorte on Any good tutorials & tips for v17 Data API? thanks!
  • I have the Postman set working: I can log in, get an auth token & do further requests.
  • In FM, I've created a new table API request, and added a simple text field JSON data.
  • I'm able to POST an easy string into the API request table

 

The object I'm expecting looks a bit like this:

{

  "type": "order",

  "event": "create",

  "object": 1463

}

so basically it informs FM that there's a new order, with the key, and then I can go fetch al data.

 

I could cheat, and ask the website to send exactly this JSON:

{

  "fieldData":

  {

    "event": "create",

    "type": "order",

    "key": 1463

    }

}

and tune my table to have exactly these fields. That will solve my problem for now - but it's kinda cheeting...

I would have to create a designed table for each JSON type of request - that doesn't scale. It wouldn't handle nested objects as well...

 

So how do I store a JSON object into a field?

Or how do I set up an easy POST endpoint that accepts any JSON type of object?

 

Further info:

  • I'm using Filemaker Server 17,
  • have Data API up for a certain rest user

Outcomes