I'm trying to use the API of Trello via the library they provide, client.js:https://trello.com/docs/gettingstarted/clientjs.html
I have:
<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 and myIDListInsertedHEre are replaced with the actual values.
Console.log shows a valid value for token however the POST command gets rejected, it says: POST https://api.trello.com/1/cards 400 (Bad Request)
As far as I can tell from the documentation for this (https://trello.com/docs/api/card/#post-1-cards) I am formatting this correctly...any ideas to what I'm doing wrong?
The post request is showing an invalid value for idList
since the parameter name has a lowercase "L" in your request. If you capitalize that, it should work fine.