I am trying to use the supportsync API ( https://help.supportsync.com/crm/api/help ) to extract a table of returns in my company's data.
I am able to use many of the post and get methods without a problem, but when I use the "GetReturnList" post, I am receiving the following error message: "Message":"Object reference not set to an instance of an object. at SupportSyncCRM"
This is the specific API post I am trying to use: https://help.supportsync.com/crm/api/help/Api/POST-api-app-Returns-GetReturnList
I have tried using json as opposed to data for my payload, but that does not seem to change anything. And oddly, I have had no issue using other methods within the API.
Below is a snippet of my code:
URL = 'https://[mycompany].supportsync.com/crm/api/app/Returns/GetReturnList'
headers = {'Authorization': 'Basic ' + auth.decode('ascii'), 'Content-Type':'application/json'}
payload = {'PageSize':'500', 'ReturnListType':'Receiving', 'SearchType':'0'}
r = requests.post(URL, headers=headers, data=payload)
print(r.status_code)
print(r.text)
print(r.json)
Here is the output generated by my print statements:
400
{"Message":"Object reference not set to an instance of an object. at SupportSyncCRM"}
<bound method Response.json of <Response [400]>>
Reading the documentation more closely, the app
in your URL is not correct - it should not be the literal text app
, but instead:
{app} is the application making the request, such as: zendesk
So I reached out to their support team and they responded with this:
Here's a sample of the POST. Make sure you have all these fields:
{ "PageIndex":0, "PageSize":50, "SortColumn":"", "CustomerID":"", "CustomerEmail":"", "ReturnListType":"", "FlagGroupId":"", "FlagReason":"", "SearchText":"", "SearchType":0, "ReturnTypeId":"", "CarrierMethodId":"", "IsCrossShip":"", "IsPrepaidReturnLabel":"", "CreatedByUserId":"", "ProductId":"", "ReturnReasonId":"", "PaymentRequired":0, "CreatedDateFrom":"", "CreatedDateTo":"" }
I then altered my code to include every field in the payload and changed this line:
r = requests.post(URL, headers=headers, json=payload)
My response is now appropriately communicating with the server.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.