ExactOnline API multiple HTTP requests not working properly on automation platforms

I’m having trouble with my ExactOnline API integration script. The code works perfectly when I test it on my local machine, but it breaks when I deploy it to automation platforms like Zapier or n8n.

The issue seems to happen specifically with multiple API calls. On Zapier, the execution stops right before making fetch requests. Here’s my current implementation:

const authToken = 'my_token_here';
const companyDivision = 'division_id_here';

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

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

async function processActions(actionType) {
  if (actionType === "create_client_and_person") {
    const clientResult = await createClient(clientData);
    const newClientId = clientResult;
    
    personData.Account = newClientId;
    const personResult = await createPerson(personData);
    
    return 'Processing completed successfully';
  }

  async function createClient(data) {
    console.log('Creating client record');
    const response = await makePostRequest(1, data);
    return response.d.ID;
  }

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

  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 ${authToken}`,
        'Content-Type': 'application/json'
      },
      body: JSON.stringify(payload)
    });
    
    return await response.json();
  }

  async function updateClientRecord(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 ${authToken}`
      },
      body: JSON.stringify(updatePayload)
    });
  }
}

async function executeProcess() {
  console.log("Starting process");
  await processActions("create_client_and_person");
  return "Process completed";
}

output = [executeProcess()];

Has anyone experienced similar issues with ExactOnline API calls on these platforms? What could be causing the difference in behavior between local and cloud execution?

Had this exact issue with ExactOnline API on automation platforms. The problem’s usually Promise resolution - your output = [executeProcess()] line creates an array with a pending Promise, not the actual result. Change it to output = await executeProcess() or use .then() to wait for completion. Automation platforms have stricter timeouts than local environments, so add error handling and maybe delays between sequential API calls. Also found that some platforms hate nested async functions. Flatten your structure and don’t define async functions inside other async functions. Token refresh timing acts differently on these platforms too.

This sounds like a token handling issue between environments. ExactOnline tokens have strict validation requirements, and automation platforms handle them differently than local runs. Your Bearer token’s probably expiring or getting killed during the multi-step process. I’ve hit this exact problem moving ExactOnline integrations to cloud platforms - the token refresh cycle gets weird. Add token validation before each API call and grab the division ID dynamically instead of hardcoding it. Also throw try-catch blocks around your fetch operations to see the actual error responses. Automation platforms love masking network failures you’d catch locally. Your sequential calls might also be hitting rate limits that don’t show up in local testing.

zapier and n8n handle http requests differently than your local setup. add proper error handling to your fetch calls and check if the response is actually ok before parsing json. also, automation platforms often limit requests per execution - exact online might be throttling your rapid-fire api calls. add delays between requests or use promise.all() for parallel processing instead of sequential awaits.