Trello POST FAIL

81 views Asked by At

I want to use the post method of the following link: https://developers.trello.com/advanced-reference/checklist#post-1-checklists-idchecklist-checkitems

I understand that I would have to add an element to the specified checklist, but I do not know why I did not create the new element.

My code:

https://api.trello.com/1/checklists/[idChecklist]/checkItems?name=[NAME_NEW_ELEMENT]&key=[TRELLO_KEY]&token=[MY_TOKEN]

I don't know if name=[NAME_NEW_ELEMENT] is correct. How do I write it to add an element? Thanks in advance.

2

There are 2 answers

0
Sangbok  Lee On

No name=... in the URL. I've tested some POST with JavaScript and it works well. You can test this code in any browsers.

var CL_ID = "YOUR CHECKLIST ID"
var API_KEY = "YOUR TRELLO API KEY";
var TOKEN = "YOUR TRELLO TOKEN";

var payload = {"name": 'item4'};
var blob = new Blob([JSON.stringify(payload)], {type: 'application/json'});
var url = 'https://api.trello.com/1/checklists/'+CL_ID+'/checkItems?key='+API_KEY+'&token='+TOKEN;

var xhttp = new XMLHttpRequest();
xhttp.open("POST", url, true);
xhttp.onload = function() {
  if(xhttp.status === 200) {
    var response = xhttp.responseText;
    console.log(response);
  }
};
xhttp.send(blob);
0
Karl Pokus On

It's not clear what you want to do here. Do you want to A. Create a new checklist? or B. Add an item to an existing checklist?

If A use this, if B use this.