我正在使用 Hubspot API,并尝试通过“PUT”方法发送 JSON 数据来修改交易的结束日期。但我收到诸如
之类的错误{ status: 'error', message: 'Invalid input JSON on line 1, column 15: Can not deserialize instance of java.util.ArrayList out of START_OBJECT token', correlationId: 'b8b47229-184d-40b3-b402-9e3dd684b217', requestId: 'd364fe8dac5e876639928dd0d04045fd' }
这是我写的代码-
fetch('https://api.hubapi.com/deals/v1/deal/103361780?hapikey=', {
method: 'put',
headers: {
'Accept': 'application/json, text/plain, */*',
'Content-Type': 'application/json'
},
body: JSON.stringify({"properties":{name: "closedate", "value": 1528744207881}})
}).then(res=>res.json())
.then(res => console.log(res));
这是我试图传递的 JSON 数据
{
"properties":[
{
"name": "closedate",
"value": 1528744207881
}
]
};
和here是通过 Hubspot API 发出 PUT 请求的文档。 我能够通过 POSTMAN 成功更新该值。
任何有关此事的帮助将不胜感激。
最佳答案
您缺少括号 - [] 并且在后端,它们正在等待数组将其反序列化为 Arraylist。
尝试使用此正文获取:
{"properties":[{"name": "closedate", "value": 1528744207881}]}
关于javascript - 尝试 "Put"JSON 数据时出错,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50806105/