我是trello API的新手。 正如Trello所建议的那样,我正在尝试使用client.js库。 我按照说明操作,然后在控制台中收到“成功验证”消息,但是我收到401错误(在控制台中):
POST https://api.trello.com/1/cards 401 () jquery-1.7.1.min.js:4
这是我的代码:
<head>
<title>Trello api</title>
<script src="http://code.jquery.com/jquery-1.7.1.min.js"></script>
<script src="https://api.trello.com/1/client.js?
key=[my key]"></script>
</head>
<body>
<script>
var authenticationSuccess = function() { console.log('Successful
authentication'); };
var authenticationFailure = function() { console.log('Failed
authentication'); };
Trello.authorize({
type: 'popup',
name: 'Getting Started Application',
scope: {
read: true,
write: true },
expiration: 'never',
success: authenticationSuccess,
error: authenticationFailure
});
var myList = 'my list';
var creationSuccess = function(data) {
console.log('Card created successfully. Data returned:' +
JSON.stringify(data));
};
var newCard = {
name: 'New Test Card',
desc: 'This is the description of our new card.',
idList: myList,
pos: 'top'
};
Trello.post("cards", newCard, creationSuccess);
</script>
有什么想法吗? 感谢。
答案 0 :(得分:0)
问题是你提供了一个不存在的idList,&#39;我的列表&#39;
您需要按照此处的说明操作:https://developers.trello.com/get-started/start-building以获取正确的idList值。
&#39;
答案 1 :(得分:0)
我有同样的问题。我从http://jsfiddle.net/A3Xgk/2/获取“登录”和“注销”,它正在运行。
Trello.authorize({
interactive: false,
success: onAuthorize
});
$("#connectLink").click(function() {
Trello.authorize({
type: "popup",
success: onAuthorize
});
});
如果没有帮助,请写信给我,我给你我的代码。