I have a POST request that works fine in POSTMAN, but trying to get it to work in FileMaker is less simple than I expected.
Below is the CURL command in progress. I've beat my head against the wall for about 2 hours after getting the same POST to work in about five minutes in POSTMAN and another 2 minutes in Python.
Not really. I had to put the \" back into the CURL to get it to authenticate again.
This API has a python interface so we'll just go that route.
Normally, I can get the INSERT FROM URL to work, but I've always been surprised how much we're on our own (compared with how POSTMAN works) to get the CURL options to be formatted 'Just so'. The FMP CURL Options have always seemed "half done" to me.
Agree the FileMaker CURL options are somewhat awkward.
One idea is to build your own mini version of Postman for testing, e.g. have each CURL option separated into its own Key / Value fields, and then have a script handle all the calcultions for you, to ensure that quoting is done by machine rather than by hand.
Another idea is to use the --show-error options as described here:
Handling errors
Unsupported cURL options are ignored.
If you use the --show-error option:
When errors returned by the cURL library cause FileMaker clients to return error code 1631 via the Get(LastError) functionto indicate an unspecified connection failure, the Get(LastErrorDetail) function returns the same text that the curl command-line tool returns.
That's nice. When I try to run it, though, it says not enough parameters, but doesn't specify exactly what's wrong. It's ironic that the CF editor doesn't have a debugging capability ether. LOL.
Just a follow up that, unfortunately, the code you posted did not work and resulted in an authorization failure. It seems the \" may really be needed. Since I don't control the service side of this API, I'm unable to figure out why it's so picky.
Manual quoting is always tricky and should best be avoided by using Quote() as suggested by @xochi
I also noticed that the payload you created is not valid JSON. Try the following formula in a set variable, it creates all variables you'd for the insert-from-url. You just need to fill in the url and the api-key in there:
Then use $url and $options in your IFU scriptstep. The reason for the list() in the $options is that FileMaker will convert the ΒΆ-separated $options into space-separated by itself.
Compare the payload for the correct syntax with the one you succesfully used in Postman, before you use it