Search code examples
google-apps-scripttrellohttp-put

Trello API Moving Card to another List using Google Apps Script


I trying to use Google Apps Script to move a filtered set of cards from one list to another in Trello using their API and this method:

https://trello.com/docs/api/card/index.html#put-1-cards-card-id-or-shortlink-idlist

But I keep getting the following error message:

Request failed for returned code 404. Truncated server response: Cannot PUT /1/cards/54aa79112b9cdbb78fe43abf/5419475e4948228f2be857bd

My code looks like this:

var url = 'https://api.trello.com/1/cards/'+*ID OF CARD TO BE MOVED*+'/'+*ID OF LIST TO MOVE CARD TO*

var options = {
       "method": "PUT",
       "oAuthServiceName": "trello",
       "oAuthUseToken": "always"
        };

UrlFetchApp.fetch(url, options);

Any idea on what I am doing wrong? Do I need to add a payload to the options (so far have only done get and pull requests and it has all worked via the url rather than a payload) if so what would that be the documentation isn't that clear.

Otherwise any other thoughts on what the problem might be


Solution

  • The route you're trying to use is described as PUT /1/cards/[card id or shortlink]/idList - in this specific case, it looks like you want PUT /1/cards/54aa79112b9cdbb78fe43abf/idList. Then, the payload is described in the Arguments section - there should be a single argument named value, and its value is the id of the list.