我试图通过他们提供的库来使用Trello的API,client.js:https://trello.com/docs/gettingstarted/clientjs.html
我有:
<script src="./js/jQuery.js"></script>
<script src="https://api.trello.com/1/client.js?key=myAPIInsertedHere"></script>
<script>
$(document).ready(function(){
Trello.authorize({
interactive: true,
type: "popup",
expiration: "never",
name: "surveyrequest",
persist: "true",
success: function() { onAuthorizeSuccessful(); },
error: function() { onFailedAuthorization(); },
scope: { read: true, write: true},
});
function onAuthorizeSuccessful() {
var token = Trello.token();
today = new Date("December 25, 2015 12:00:00");
var thisUrl = encodeURL = "http://www.google.com/";
console.log(token);
Trello.post("cards", { name: "Card created for test", desc: "this is a test", idlist: "myIDListInsertedHere", due: today, urlSource: thisUrl});
}
function onFailedAuthorization() {
console.log("Authorization failed.");
}
});
</script>
MyAPIInsertedHere和myIDListInsertedHEre将替换为实际值。
Console.log显示令牌的有效值,但POST命令被拒绝,它说: POST https://api.trello.com/1/cards 400(错误请求)
据我从文档中可以看出这一点(https://trello.com/docs/api/card/#post-1-cards)我正确地格式化了这个......我对错误做了什么想法?
答案 0 :(得分:3)
发布请求显示idList
的值无效,因为参数名称在请求中的小写“L”。如果你把它弄清楚,它应该可以正常工作。