简体   繁体   中英

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

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.

I'm new in app scritps but i have this solution for your problem

function UpdateTrelloCard() {
    var IDcard = "..."
    var idafterlist = "...";
    var options = {
       'method' : 'put',
    };
    var response = UrlFetchApp.fetch(url + "cards/" + IDcard + "?idList=" + idafterlist + "&key=" + api_key + "&token=" + api_token, options);
    var lists = JSON.parse((response.getContentText()));
    Logger.log(idtrello)
    Logger.log(lists)
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM