可能原因是请求中未包含必要的字段或者格式不正确,可以参考以下示例代码进行修改:
import requests
import json
url = 'https://myacumaticasite.com/entity/Default/18.200.001/SalesOrder'
headers = {'Content-Type': 'application/json'}
payload = {
"Type": { "value": "SO" },
"CustomerOrder": { "value": "1001" },
"OrderDate": { "value": "2022-01-01T00:00:00" },
"Details": [
{
"InventoryID": { "value": "ITEM001" },
"Quantity": { "value": 5 },
"WarehouseID": { "value": "WAREHOUSE001" },
"UnitPrice": { "value": 10 }
}
]
}
response = requests.put(url, headers=headers, data=json.dumps(payload))
print(response.status_code)
print(json.loads(response.content))
在以上示例代码中,我们通过设置请求头类型为“application/json”和将payload数据转化为json字符串发送PUT请求,以创建销售订单记录。