{ "nodes": [ { "name": "On clicking 'execute'", "type": "n8n-nodes-base.manualTrigger", "position": [ 200, 470 ], "parameters": {}, "typeVersion": 1, "id": "list-all-hubspot-contacts-with-pagination-0" }, { "name": "Read contacts", "type": "n8n-nodes-base.httpRequest", "typeVersion": 4.2, "parameters": { "url": "https://api.hubapi.com/crm/v3/objects/contacts?limit=100", "authentication": "genericCredentialType", "genericAuthType": "httpHeaderAuth", "options": { "response": { "response": { "responseFormat": "json", "fullResponse": true } }, "pagination": { "pagination": { "paginationMode": "responseContainsNextURL", "nextURL": "={{ 'https://api.hubapi.com/crm/v3/objects/contacts?limit=100' + ($pageCount === 0 ? '' : '&after=' + encodeURIComponent($response.body?.paging?.next?.after ?? '')) }}", "paginationCompleteWhen": "other", "completeExpression": "={{ (()=>{const p=$response.body?.paging;if(p!=null&&(typeof p!=='object'||Array.isArray(p)))throw Error('Invalid HubSpot paging');const n=p?.next;if(n!=null&&(typeof n!=='object'||typeof n.after!=='string'||!n.after))throw Error('Invalid HubSpot cursor');return n==null})() }}", "requestInterval": 5000, "limitPagesFetched": false } } } }, "id": "list-all-hubspot-contacts-with-pagination-1" }, { "name": "Collect contact pages", "type": "n8n-nodes-base.code", "typeVersion": 2, "parameters": { "mode": "runOnceForAllItems", "jsCode": "const rows=[];for(const {json} of $input.all()){const b=json.body;if(!b||!Array.isArray(b.results))throw Error('Invalid HubSpot page');for(const x of b.results)rows.push({json:x})}return rows;" }, "id": "list-all-hubspot-contacts-with-pagination-2" } ], "connections": { "On clicking 'execute'": { "main": [ [ { "node": "Read contacts", "type": "main", "index": 0 } ] ] }, "Read contacts": { "main": [ [ { "node": "Collect contact pages", "type": "main", "index": 0 } ] ] } }, "name": "List HubSpot Contacts with Pagination", "active": false, "pinData": {} }