March 21, 20187 yr I am having trouble with the UPS JSON API. I know it has been done here before, because I have seen questions about decoding the return. UPS doesn't like what I am sending. I am using JSONSetElement to create my JSON: JSONSetElement ( "{}"; ["UPSSecurity"; ""; JSONObject]; ["UPSSecurity.UsernameToken"; ""; JSONObject]; ["UPSSecurity.UsernameToken.Username"; "psamuelson"; JSONString]; ["UPSSecurity.UsernameToken.Password"; "xxxxxx"; JSONString]; ["UPSSecurity.ServiceAccessToken"; ""; JSONObject]; ["UPSSecurity.ServiceAccessToken.AccessLicenseNumber"; "ABCABC"; JSONString]; ["TrackRequest"; ""; JSONObject]; ["TrackRequest.Request"; ""; JSONObject]; ["TrackRequest.Request.RequestOption"; "1"; JSONString]; ["TrackRequest.Request.TransactionReference"; ""; JSONObject]; ["TrackRequest.Request.TransactionReference.CustomerContext"; "Your Test Case Summary Description"; JSONString]; ["TrackRequest.InquiryNumber"; "1Z5690980355503859"; JSONString] ) Which creates the following JSON, after a JSONFormatElements : { "TrackRequest" : { "InquiryNumber" : "1Z5690980355503859", "Request" : { "RequestOption" : "1", "TransactionReference" : { "CustomerContext" : "Your Test Case Summary Description" } } }, "UPSSecurity" : { "ServiceAccessToken" : { "AccessLicenseNumber" : "ABCABC" }, "UsernameToken" : { "Password" : "XXXXXX", "Username" : "psamuelson" } } } The UserName and Password are for my UPS account. The AccessLicenseNumber is my Access Key from UPS. The format of my XML appears to match the JSON example from their documentation, other than the order of objects (FileMaker seems to list them in alphabetical order), but I don't think that matters. The URL is "httpspost://wwwcie.ups.com/rest/Track?"& $$UPS_JSON_Formatted (where $$UPS_JSON_Formatted is my variable containing the JSON above). I am using cURL options "--header \"Content-type: application/json\" --data-urlencode" The response I get back from UPS is {"Error":{"Code":"4","Description":"JSON Syntax error"}}. I think the JSON is correct, so I wonder if I am missing something with cURL options or something else. Any ideas? Thanks, Paul
March 22, 20187 yr I do not know about UPS api but try by setting data as --data option. Instead of "httpspost" format in url, use curl options with data set from variable. Below is example (did just wrote from memory, not sure if syntax is 100% correct) "--data @$$UPS_JSON_Formatted " & "-X POST " & "-H \"Content-type: application/json\"" Set url as "https://wwwcie.ups.com/rest/Track" Edited March 22, 20187 yr by jvagla
April 26, 20196 yr Newbies On 3/22/2018 at 2:23 PM, PaulSamuelson said: That did it. Thanks! Now, on to decoding the returned data... Thanks, Paul Hi Paul, I still can't get this to work properly. Would you please post the working code of your "Track Request" Thanks Gary
Create an account or sign in to comment