AnsweredAssumed Answered

Insert From URL cURL Options Data Issues

Question asked by alecgregory on Jul 19, 2017
Latest reply on Jul 23, 2017 by RALees

I am having various issues including data in the cURL Options of Insert From URL. It seems that the data is not being sent at all or being sent incorrectly. The example below uses the FileMaker Data Api as this should be something that others can test.

 

I am able to successfully obtain a token using Insert From URL using the following options:

 

-X POST -H "Content-Type: application/json" -d {"layout":"Transaction","password":"<password>","user":"<username>"}

 

I then attempt a PUT request with Insert From URL to update a record by setting the following cURL options:

 

Let (

     $data =

          JSONSetElement (

               "";

               "data";

               JSONSetElement (

                    "";

                    "Title";

                    "Artwork - Updated By The REST API";

                    JSONString

               );

               JSONObject

          );

     "-X PUT"

          & " -H \"Content-Type: application/json\""

          & " -H \"FM-Data-token: "

          & $token

          & "\""

          & " -d @$data"

)

 

When running the request using Insert From URL the response is:

 

{"errorMessage":"Data is missing.","errorCode":"10"}

 

The response header is:

 

HTTP/1.1 415 Unsupported Media Type

Date: Thu, 06 Apr 2017 14:28:01 GMT

Server: Apache/2.4.25 (Unix) LibreSSL/2.2.7

Content-Type: application/json; charset=utf-8

Content-Length: 41

ETag: W/"29-4JiBp9g8zSbEXaQYl2hHsg"

Vary: Accept-EncodingX-Frame-Options: SAMEORIGIN

X-XSS-Protection: 1; mode=block

X-Content-Type-Options: nosniff

 

When running the PUT request using the BaseElements function BE_HTTP_PUT_DATA and using the JSON

 

{"data":{"Title":"Artwork - Updated By The REST API"}}

 

as the data parameter the request works as expected: I get the JSON response "OK" and the record is updated. With BaseElements the options and headers are set using a separate function so they aren't passed in the data parameter.

 

I've tried formatting the data in all the ways suggested in the JSON section of the help file. E.g. --data @$data and literals. But nothing seems to work. From the errors it seems like the FileMaker Data API just isn't seeing the data. I've had the same issue with other APIs too.

 

Has anyone been able to pass data to the FileMaker Data API in the cURL Options of Insert From URL? If so, I'd appreciate it if you could share your method.

Outcomes