Getting all items from Trello API Call

I have the current workflow where I call the Trello API for all the cards on a board and then filter the cards out by label using the IF statement. I then call the API again to get the checklists for the cards that passed the IF statement. I would like to send the checklist items to google sheets. In the Get Ingredients node I get 2 results (the 2 cards that passed the IF statements), the first result has 27 items each containing 8 keys. The second result has 7 items each containing 8 keys. I would like to send all of the items to google sheets along with one particular key for each of the items to google sheets. However I can only get the first item of each of the result to go to the sheet and not all 34 items. What do I need to do between the Get Ingredient and Google Sheets to send all to the sheet?

Hey @Colin_Cameron!

Can you please share the output returned by HTTP Request node? Also, is there a particular reason you’re using the HTTP Request node instead of the Trello node?

(I am changing this post to a question since it is more of a question than a Feature Request. Please let me know if I understood it wrong)

I originally tried the Trello node but unless I’m missing something it lacks the functionality to do what I want. The output of the Get Ingredients request node looks like:

I am most interested in sending “name” to Sheets but can only get the first item from each result to go.

You can list all the checklists in a Trello card using checklist:getAll. Did you try it?

Using the HTTP node, you will need one more step to parse the data to something n8n understands. I will encourage you to use the Trello node unless I’m missing something.

@Colin_Cameron let me know.

There’s no difference between the HTTP Request and the Node. I get the similar information from both(the Node actually returns checklists that I am not interested in). It still leads me to the issue above where I cannot pass all of the items to google sheets only the first one of each result.

There is a big difference, the node returns the data with the right structure, and the HTTP node does not. If you add a function node after the get ingredients with the following code, it should fix the problem.

const results = []

const ingredients = items[0].json

for (const ingredient of ingredients) {
    results.push({ json: ingredient })
}

return results;

Trello Node results and a set node:


Request and set node:


What’s different? I get the exact same thing from each on the set node.

Likely in the set node, you’re referencing the first array element of each item.

Item is an object in the top level array. So when getting all cards, it works since each card is not an array, but a single object. But when you fetch checklist item for each card, you’re now getting an array of checklist items for each card.
So 1 item = card
And afterwards 1 item = 1 array of checklist items.

If you want to turn each checklist item into a sheet row, you’ll need a function node to transform the data prior to loading into a spreadsheet node.

Here is an example, I created a simple object with only two key:values but should be a good guide for your specific case:

  "nodes": [
    {
      "parameters": {
        "functionCode": "var newItems = [];\n//var length = items.length;\n\n\n//first for loop iterates over each item (an array of checklist objects)\nfor(i=0; i< items.length; i++) {\n  //Second for loop iterates over each checklist array, and pushes each checklist item to a newItems\n  for(y=0; y < items[i].json.length; y++) {\n    newItems.push({ json: items[i].json[y]});\n  }\n  \n\n}\n\n//Now each checklist item is in a flat array (no objects), and we return it, so the output of this node is this newItems array\nreturn newItems;\n"
      },
      "name": "Function",
      "type": "n8n-nodes-base.function",
      "typeVersion": 1,
      "position": [
        720,
        310
      ]
    },
    {
      "parameters": {},
      "name": "Start",
      "type": "n8n-nodes-base.start",
      "typeVersion": 1,
      "position": [
        250,
        300
      ]
    },
    {
      "parameters": {
        "functionCode": "items[0].json = [\n  {\n      name: \"3 tablespoons vegetable\",\n      state: \"incomplete\"\n  },\n  {\n      name: \"canola\",\n      state: \"complete\"\n  },\n  {\n      name: \"or peanut oil\",\n      state: \"incomplete\"\n  }\n\n];\nitems.push({json: [\n  {\n      name: \"5 tablespoons vegetable\",\n      state: \"incomplete\"\n  },\n  {\n      name: \"olive oil\",\n      state: \"complete\",\n  },\n  {\n      name: \"or peanut oil\",\n      state: \"incomplete\"\n  }\n\n]});\n\nreturn items;"
      },
      "name": "Mock data",
      "type": "n8n-nodes-base.function",
      "typeVersion": 1,
      "position": [
        450,
        310
      ]
    },
    {
      "parameters": {
        "functionCode": "var newItems = [];\n//var length = items.length;\n\n\n//first for loop iterates over each item (an array of checklist objects)\nfor(i=0; i< items.length; i++) {\n  //Second for loop iterates over each checklist array, and pushes each checklist item to a newItems\n  for(y=0; y < items[i].json.length; y++) {\n    newItems.push({ json: items[i].json[y]});\n  }\n  \n\n}\n\n//Now each checklist item is in a flat array (no objects), and we return it, so the output of this node is this newItems array\nreturn newItems;\n"
      },
      "name": "Function",
      "type": "n8n-nodes-base.function",
      "typeVersion": 1,
      "position": [
        720,
        310
      ]
    }
  ],
  "connections": {
    "Start": {
      "main": [
        [
          {
            "node": "Mock data",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Mock data": {
      "main": [
        [
          {
            "node": "Function",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}

There are definitely cleaner shorthands for doing what I am above with the two for() loops, but hopefully it makes the “how” clearer.

Sidenote: we are working towards having some transform nodes so things like this could be achieved without a function node. Will add this case to my list!

1 Like

@Colin_Cameron did the solution above help?