Handling Data API errors with error.SetFromDAPI

The HTTP script (source: GitHub - proofgeist/mfm-http: A single script that can handle all HTTP requests with Filemaker) has been immensely helpful for handling all of my API calls. I’ve been using the Data API more often and I have found the error.SetFromDAPI custom function to be useful in parsing out the DAPI response object for errors. I wonder if this could be incorporated into the HTTP script for handling DAPI responses.

Well we wouldn’t want to add that to the HTTP script itself since that is a generic HTTP script that is used to call all kinds of APIs. It isn’t just for calling the FileMaker Data API.

But you could certainly write a wrapper script that called the HTTP Script and handled the DAPI errors.

Typically this is what I do for every API I am working with the HTTP Script. I write a wrapper script that handles the particulars of that API. It handles things like how the path is constructed, how Authentication is handled, and how the response is handled.

Then I just use that for all the requests to that API.

Make sense?

Todd

This makes sense :slight_smile:

Thanks for the advice - I will add the handling to my wrapper script