【发布时间】:2014-02-01 16:51:15
【问题描述】:
创建节点 CLI 以从 CL 创建存储库,但在发布到 github api 时出现问题。我正在使用请求模块发布到 github API。
request.post({
url: 'https://api.github.com/user/repos',
headers:{
'User-Agent': 'git CL - node',
'Content-type': 'application/json'
},
auth:{
username: '-username-',
password: '-password-'
},
form:{
name: "a-new-repo"
}
}, function(err, res, body){
console.log(body);
});
我得到的错误是{"message":"Problems parsing JSON","documentation_url":"http://developer.github.com/v3"}
我尝试了很多东西,比如
- 设置多部分数据
- 正文而不是表单数据
- 设置内容类型
- 以 JSON 格式发送
我知道的都是对的
- 身份验证 --- 如果我执行 GET 请求,我能够得到正确的响应,它只是 POST
- POST 路径和标题
github-api的链接
【问题讨论】:
标签: javascript json node.js api github-api