Today I have been working on a small internal integration with the Project Management application TeamWork. I had tested in Postman a POST request that had successfully created a task but when replicated in FileMaker with the following cURL Header Options had generated an error as illustrated below:
"curl -X POST -H 'Accept: application/json' -H 'Content-Type: application/json' -u 'xxxxMyTokenxxxx'" & " -d @$data"
? * Line 1, Column 1
Syntax error: value, object or array expected.
* Line 1, Column 1
A valid JSON document must be either an array or an object value.
After a little investigation I came across a 2017 DevCon presentation by Steve Winter [Explore cURL for FileMaker (Innovation 004) - YouTube ] illustrating many good disciplines in terms of formatting requests but in my circumstances highlighting the dangers of adding unwanted spaces within a string and how important it is to correctly comment these out. As a result I amended my cURL Header Options to the following:
"curl -X POST -H \"Accept: application/json\" & -H \"Content-Type: application/json\" & -u \"xxxxMyTokenxxxx\"" & " -d @$data"
Result = Success.
Many thanks to Steve Winter for his presentation and getting me back on track.