March 31, 20232 yr Greetings, I am attempting to post data to an API. This is the sample from the company: curl -X POST "https://123456" -H "accept: text/plain" -H "Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6IjEwMjQiLCJ1bmlxdWVfbmFtZSI6IkdyYWluIFNjYWxlIFRlc3QiLCJTZXJ2ZXJOYW1lIjoiREVWVEVTVDUiLCJEYXRhYmFzZU5hbWUiOiJURVNUUExBWSIsInJvbGUiOlsiV3JpdGUiLCJHcmFpblNjYWxlIl0sIm5iZiI6MTY4MDIyODE1MywiZXhwIjoxNjgwMzE0NTUzLCJpYXQiOjE2ODAyMjgxNTN9.yhqi6tMddjt7xyFj1tV4pzJkAPIcpf_hTJtyrH8mrwc" -H "Content-Type: application/json" -d "{\"JobID\":\"string\",\"TicketID\":\"string\",\"LocationID\":0,\"CustID\":0,\"GradeID\":0,\"ElevatorReceiptNo\":\"string\",\"LoadID\":\"string\",\"ScaleGrossWeight\":0,\"ScaleTareWeight\":0,\"ScaleNetWeight\":0,\"Dockage\":0,\"CarrierID\":0,\"OrderNumber\":\"string\",\"Comments\":\"string\",\"ScaleTicketGradingFactors\":[{\"GradingFactorID\":0,\"GradingFactorValue\":0}]}" The FileMaker JSON array that I built is formatted differently. Primarily missing all the back slashes and missing the data types. Is there a workaround for this, or am I doing something wrong? JSONSetElement ( "{}" ; [ "JobID" ; Shipping Scale Ticket::JobID ; JSONString ]; [ "TicketID" ; Shipping Scale Ticket::TicketID ; JSONString ] ) -X POST "https:/123456" -H "Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6IjEwMjQiLCJ1bmlxdWVfbmFtZSI6IkdyYWluIFNjYWxlIFRlc3QiLCJTZXJ2ZXJOYW1lIjoiREVWVEVTVDUiLCJEYXRhYmFzZU5hbWUiOiJURVNUUExBWSIsInJvbGUiOlsiV3JpdGUiLCJHcmFpblNjYWxlIl0sIm5iZiI6MTY4MDIzMzMzOSwiZXhwIjoxNjgwMzE5NzM5LCJpYXQiOjE2ODAyMzMzMzl9.GfLOdsxyXDN7egKUUPZz-hwEqcBdQ41GYiYkfwNiQm8" -H "Content-Type: application/json"-d "{"JobID":"1","TicketID":"ss1"}" This is the error message that I get: ? * Line 1, Column 1 Syntax error: value, object or array expected. TIA John
March 31, 20232 yr I don't think you need to bother escaping the quotes in your JSON. You should be able to put the JSON in a variable and post it from there - see: https://fmforums.com/topic/108984-implementing-insert-from-url-targetresulthttpsgraphmicrosoftcomv10mesendmail/?do=findComment&comment=488850&_rid=72594 However, you may have to add all the missing elements shown in their example. Hard to tell without seeing their documentation.
March 31, 20232 yr Author Seems to be a problem with the insert URL script step. If I paste the FileMaker generated code via Run Curl Commands Online (reqbin.com) it works. Wondering if there is an alternative method to post from FileMaker. Maybe a plugin?
March 31, 20232 yr 50 minutes ago, John F said: Seems to be a problem with the insert URL script step. I don't think so. But it is difficult for me to give you specific advice without knowing exactly (a) what you did and (b) what you should do (i.e. what are the API's specifications). 52 minutes ago, John F said: If I paste the FileMaker generated code via Run Curl Commands Online (reqbin.com) it works. That doesn't mean anything. I thought you would know that, since you said here you have read this. 54 minutes ago, John F said: Maybe a plugin? The BaseElements plugin does offer an alternative method. So does MBS and perhaps others. But IMHO your problem is not with the tool but with what to do do with it.
March 31, 20232 yr Author Comment, thanks for your help. I followed your lead and did some more reading. I found one error and that got me a step further. Now I am stuck on: { "errors" : { "$" : [ "Expected depth to be zero at the end of the JSON payload. There is an open JSON object or array that should be closed. Path: $ | LineNumber: 0 | BytePositionInLine: 1." ] }, "status" : 400, "title" : "One or more validation errors occurred.". I am only posting 1 record. There is very little documentation with the API. I used the data parser downloader from the Solian site and it didn't flag any issues.
Create an account or sign in to comment