Help! Map Records Function only Returning First 100 items

This post was flagged by the community and is temporarily hidden.

Having a look. Btw you gotta be careful. You just exposed your API Key. I edited your post to remove it.

Ok it seems the working as expected. The HTTP request just returns 97 items. Those 97 items can be processed in one batch. Am I missing something?

Yes I had to delete some test users so that it would perform correctly. For some reason when there were over 100 the Map Records module would only do 100. Let me add some more test users back in.

Alright @RicardoE105 just sent you a message.

Check the example below. Remember to add the API Key.

{
  "nodes": [
    {
      "parameters": {},
      "name": "Start",
      "type": "n8n-nodes-base.start",
      "typeVersion": 1,
      "position": [
        250,
        300
      ]
    },
    {
      "parameters": {
        "path": "adastacks-email-verification",
        "responseCode": 303,
        "options": {
          "responseHeaders": {
            "entries": [
              {
                "name": "Location",
                "value": "https://adastacks.com/email-confirmed"
              }
            ]
          }
        }
      },
      "name": "Webhook",
      "type": "n8n-nodes-base.webhook",
      "typeVersion": 1,
      "position": [
        290,
        750
      ],
      "webhookId": "5903a5ad-575b-491d-b3a4-0fd7ad9a6709",
      "disabled": true
    },
    {
      "parameters": {
        "conditions": {
          "string": [
            {
              "value1": "={{$item(0).$node[\"Webhook\"].json[\"query\"][\"user\"]}}",
              "value2": "={{$node[\"Map Records\"].json[\"API Key\"]}}"
            }
          ],
          "number": []
        }
      },
      "name": "IF",
      "type": "n8n-nodes-base.if",
      "typeVersion": 1,
      "position": [
        1310,
        690
      ],
      "alwaysOutputData": false
    },
    {
      "parameters": {
        "url": "=https://api.adalo.com/v0/apps/8898ed2f-3b12-4479-92fe-25db70600bd1/collections/t_0814daf2284748158d3bf16992e2657c?offset={{$node[\"Set\"].json[\"next\"]}}",
        "options": {},
        "headerParametersUi": {
          "parameter": [
            {
              "name": "Authorization",
              "value": "Bearer"
            },
            {
              "name": "Content-Type",
              "value": "application/json"
            }
          ]
        },
        "queryParametersUi": {
          "parameter": []
        }
      },
      "name": "Get All Adastacks Users",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 1,
      "position": [
        730,
        300
      ]
    },
    {
      "parameters": {
        "conditions": {
          "string": [],
          "boolean": [
            {
              "value1": "={{$node[\"Get All Adastacks Users\"].json[\"offset\"] ? true : false}}",
              "value2": true
            }
          ]
        }
      },
      "name": "IF1",
      "type": "n8n-nodes-base.if",
      "typeVersion": 1,
      "position": [
        570,
        680
      ]
    },
    {
      "parameters": {
        "values": {
          "number": [
            {
              "name": "next",
              "value": "={{$node[\"Get All Adastacks Users\"].json[\"offset\"]}}"
            }
          ]
        },
        "options": {}
      },
      "name": "Set",
      "type": "n8n-nodes-base.set",
      "typeVersion": 1,
      "position": [
        860,
        550
      ]
    },
    {
      "parameters": {
        "functionCode": "const allData = []\n\nlet counter = 0;\ndo {\n  try {\n    const items = $items(\"Get All Adastacks Users\", 0, counter).map(item => item.json);\n    allData.push.apply(allData, items[0].records);\n  } catch (error) {\n    const response = allData.map(data => ({ json: data }))\n    return response;\n  }\n\n  counter++;\n} while(true);\n\n"
      },
      "name": "Merge Results",
      "type": "n8n-nodes-base.function",
      "typeVersion": 1,
      "position": [
        1060,
        700
      ]
    },
    {
      "parameters": {
        "requestMethod": "PUT",
        "url": "=https://api.adalo.com/v0/apps/8898ed2f-3b12-4479-92fe-25db70600bd1/collections/t_0814daf2284748158d3bf16992e2657c/{{$node[\"IF\"].json[\"id\"]}}",
        "options": {},
        "bodyParametersUi": {
          "parameter": [
            {
              "name": "Account Verified",
              "value": "true"
            }
          ]
        },
        "headerParametersUi": {
          "parameter": [
            {
              "name": "Authorization",
              "value": "Bearer"
            },
            {
              "name": "Content-Type",
              "value": "application/json"
            }
          ]
        },
        "queryParametersUi": {
          "parameter": []
        }
      },
      "name": "HTTP Request",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 1,
      "position": [
        1570,
        670
      ]
    }
  ],
  "connections": {
    "Start": {
      "main": [
        [
          {
            "node": "Get All Adastacks Users",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "IF": {
      "main": [
        [
          {
            "node": "HTTP Request",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get All Adastacks Users": {
      "main": [
        [
          {
            "node": "IF1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "IF1": {
      "main": [
        [
          {
            "node": "Set",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Merge Results",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Set": {
      "main": [
        [
          {
            "node": "Get All Adastacks Users",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Merge Results": {
      "main": [
        [
          {
            "node": "IF",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}
1 Like

did it work?

1 Like

Yes it sure did! Sorry I forgot the respond! That simplified my workflows a lot! Thank you!