javascript - 从 javascript 更新 google 联系人时出现问题

标签 javascript node.js google-contacts-api

我正在使用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/

相关文章:

javascript - 我怎样才能像 javascriptobfuscator.com 这样通过 php 打包 javascript

oauth-2.0 - 获取 token ,存储它,如果过期则使用 ruby​​ 中的 oauth2 gem 刷新它

ruby-on-rails - 在 Ruby 上访问 Google 通讯录 API

node.js - MongoDB:存储的base64缓冲区数据和检索的base64不匹配

javascript - index.html 不调用 javascript 文件

ruby-on-rails - Rails-导入GMAIL联系人,然后与GMAIL同步,更新插入

javascript - 如何通过postmessage发送json

javascript - 使用 jQuery 以编程方式触发 'checked' 复选框

javascript - Instagram API,/media/recent 只显示当年的图像?

node.js - 如何在 Node JS rest API 中使参数可选