我正在使用unirest在nodejs中发送PUT请求来更新联系人。
unirest.put(url)
.header({
'Authorization': 'Bearer '+result.profileData.split('?access_token=')[1],
'If-Match': '*',
})
.send({"entry":{"phoneNumber":req.body.mobile}})
.end(function (res1) {
res.send(res1);
});
}
我收到响应:对象 {statusCode:415,正文:“Content-Type application/x-www-form-urlencoded 不是有效的输入类型。”, header :对象,请求:对象}
我以 .send({"entry":{"phoneNumber":req.body.mobile}})
形式发送数据,但我不确定这是否是正确的格式?
我没有找到任何documentation on this基于JavaScript。如有帮助,我们将不胜感激
最佳答案
您似乎需要提供内容类型 header 。因此将其添加到传递给 .headers 方法的对象中,值为 json/application
...
.headers({
"Content-Type": "application/json",
...
})
...
关于javascript - 从 javascript 更新 google 联系人时出现问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41564588/