[英]Azure Functions Python blobTrigger How do I fix “Microsoft.Azure.WebJobs.Extensions.Storage: Object reference not set to an instance of an object.”?
[英]How to fix “Object reference not set to an instance of an object” error with Python Requests
我正在尝试使用 supportsync API ( https://help.supportsync.com/crm/api/help ) 来提取我公司数据中的退货表。
我可以毫无问题地使用许多帖子和获取方法,但是当我使用“GetReturnList”帖子时,我收到以下错误消息:“消息”:“对象引用未设置为 object 的实例。在 SupportSyncCRM"
这是我正在尝试使用的特定 API 帖子: https://help.supportsync.com/crm/api/help/Api/POST-api-app-Returns-GetReturnList
我尝试使用 json 而不是我的有效负载数据,但这似乎并没有改变任何东西。 奇怪的是,我在 API 中使用其他方法没有问题。
下面是我的代码片段:
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]>>
仔细阅读文档,您的 URL 中的app
不正确 - 它不应该是文字app
,而是:
{app} 是发出请求的应用程序,例如:zendesk
所以我联系了他们的支持团队,他们的回应是:
这是 POST 的示例。 确保您拥有所有这些字段:
{ "PageIndex":0, "PageSize":50, "SortColumn":"", "CustomerID":"", "CustomerEmail":"", "ReturnListType":"", "FlagGroupId":"", "FlagReason":"", "SearchText":"", "SearchType":0, "ReturnTypeId":"", "CarrierMethodId":"", "IsCrossShip":"", "IsPrepaidReturnLabel":"", "CreatedByUserId":"", "ProductId":"", "ReturnReasonId":"", "PaymentRequired":0, "CreatedDateFrom":"", "CreatedDateTo":"" }
然后我更改了我的代码以包含有效负载中的每个字段并更改了这一行:
r = requests.post(URL, headers=headers, json=payload)
我的响应现在正在与服务器进行适当的通信。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.