ExactOnline API multiple HTTP requests failing on automation platforms like Zapier and n8n

I’m having trouble with my ExactOnline API integration script. It works perfectly when I test it on my local machine, but breaks when I deploy it to automation platforms like Zapier or n8n. The script stops executing right before making HTTP requests.

Here’s my current implementation:

const apiToken = 'your_token_here';
const companyDivision = 'division_id';

const customerInfo = {
  "Name": "business name",
  "City": "location", 
  "Website": "example.com"
};

const personInfo = {
  "FirstName": "john",
  "LastName": "doe",
  "City": "location name"
};

async function processAction(actionType) {
  if (actionType == "create_customer_and_contact") {
    const customerResult = await createCustomer(customerInfo);
    const customerId = customerResult;
    
    personInfo.Account = customerId;
    const contactResult = await createPerson(personInfo);
    
    return 'Operation completed successfully';
  }

  async function createCustomer(data) {
    const result = await makePostRequest(1, data);
    return result.d.ID;
  }

  async function createPerson(data) {
    const result = await makePostRequest(2, data);
    
    const updateData = {
      MainContact: result.d.ID
    };
    
    await updateCustomer(updateData, data.Account);
    return result.d.ID;
  }

  async function makePostRequest(requestType, payload) {
    let apiUrl = `https://start.exactonline.nl/api/v1/${companyDivision}/crm/`;
    
    if (requestType == 1) {
      apiUrl += 'Accounts';
    } else if (requestType == 2) {
      apiUrl += 'Contacts';
    }

    const response = await fetch(apiUrl, {
      method: "POST",
      headers: {
        'Accept': 'application/json',
        'Authorization': 'Bearer ' + apiToken,
        'Content-Type': 'application/json'
      },
      body: JSON.stringify(payload)
    });
    
    return await response.json();
  }

  async function updateCustomer(updatePayload, recordId) {
    const updateUrl = `https://start.exactonline.nl/api/v1/${companyDivision}/crm/Accounts(guid'${recordId}')`;
    
    await fetch(updateUrl, {
      method: 'PUT',
      headers: {
        'Content-Type': 'application/json',
        'Authorization': 'Bearer ' + apiToken
      },
      body: JSON.stringify(updatePayload)
    });
  }
}

async function executeMain() {
  await processAction("create_customer_and_contact");
  return "Process finished";
}

return executeMain();

Has anyone experienced similar issues with multiple API calls on these platforms? Any suggestions would be appreciated.

i had similar probz with zapier too. try adding some delay between your requests, it really helps. those platforms can’t handle rapid requests. also, ensure your token’s set in the env variables of the platform instead of being hardcoded.

You’re probably hitting a promise chain issue - these platforms handle async operations differently than your local setup. I’ve seen this exact thing with n8n where the execution context gets lost during sequential operations. Your function likely returns before all promises actually resolve. Flatten your code structure instead of nesting function declarations. Define everything at the top level and keep it linear. Also verify the platforms are actually getting response data from your first API call before trying the second one. Sometimes customer creation works but response parsing fails silently, breaking the contact creation step. Add logging between each step to see exactly where execution stops.

This happens because automation platforms struggle with nested async functions and promise resolution. When you declare nested functions inside processAction, it creates scope issues that fail silently on n8n and Zapier. I’ve hit this exact problem with HubSpot API integrations - the platform can’t track nested async calls properly and terminates early. Move your helper functions outside processAction to module level. Wrap each API call in try-catch blocks for proper error handling. These platforms also have tighter timeouts than local environments, so add exponential backoff for failed requests. It’ll make everything way more reliable.