Hi everyone,
I'm am trying to import all JSON data from all of the card actions on one of my boards. So far I have been able to import all lists and all cards separately but if I want to import the actions, I only manage to get some of the actions or only the latest action of that particular card.
I'm only a code noob so I can't figure out what I did wrong. Here is the code I have so far, which only show some actions of some cards but not all of the actions and cards.
var api_key = "KEY";
var api_token = "TOKEN";
var board_id = "ID";
var url = "https://api.trello.com/1/";
var key_and_token = "key="+api_key+"&token="+api_token;
function main() {
var ss = SpreadsheetApp.getActiveSheet().clear();
ss.appendRow(["ActionID", "CardID", "CardName", "Date", "Type", "Member"]);
var response = UrlFetchApp.fetch(url + "boards/" + board_id + "/actions?" + key_and_token);
var actions = JSON.parse(response.getContentText());
Logger.log(actions);
for (var i=0; i < actions.length; i++) {
var action = actions[i];
var ActionID = action.id;
if(action.type == "enablePlugin"){
var CardID = "-";
}else{
var CardID = action.data.card.id;
}
if (action.type == "enablePlugin"){
var CardName = "-";
}else{
var CardName = action.data.card.name;
}
var Date = action.date;
var Type = action.type;
var Member = action.memberCreator.fullName;
ss.appendRow([ActionID, CardID, CardName, Date, Type, Member]);
}
}
If anybody can help me, that would be great!
Hey Patrick,
You'll want to provide filter and limit query parameters to ensure that you get all types of actions: https://api.trello.com/1/boards/{idBoard}/actions?filter=all&limit=1000
The maximum number of actions you can get back in a single request is 1000. After that, you'll want to page through the remaining actions using the before query parameter. You can read more about paging here: https://developers.trello.com/docs/api-introduction#section-paging
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.