Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

Importing all card actions into Google spreadsheet

Patrick Brouwer
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
June 13, 2018

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!

1 answer

0 votes
bentley
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
June 19, 2018

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

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events