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

I built a script that handles creating and updating records through the ExactOnline API. Everything runs perfectly when I test it on my local machine, but it fails when deployed to automation platforms like Zapier or n8n.

On Zapier specifically, the script stops executing right before making HTTP requests. Here’s my implementation:

var authToken = 'your_token_here';
var companyDivision = 'division_id';

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

var PersonInfo = {
  "FirstName": "john",
  "LastName": "doe", 
  "City": "location name"
};

var resultCompanyId;

async function processAction(actionType) {
  var currentAction = actionType;
  if (currentAction == "create_company_and_contact") { 
    var companyResult = await createCompany(CompanyInfo);
    var newCompanyId = companyResult;
    
    PersonInfo.Account = newCompanyId;
    
    var contactResult = await createPerson(PersonInfo);
    var newContactId = contactResult;
    
    resultCompanyId = newCompanyId;
    
    return ('contact creation successful');
  }
  
  async function updateCompany(updateInfo, companyId) {
    var updateResult = await PUTrequest(1, updateInfo, companyId);
    console.log(updateResult);
    return ("company update successful");
  }
  
  async function createCompany(companyData) {
    console.log('creating company: ');
    var companyResponse = await POSTrequest(1, companyData);
    console.log('company creation result:' + JSON.stringify(companyResponse));
    return await companyResponse.d.ID;
  }
  
  async function createPerson(personData) {
    var personResponse = await POSTrequest(2, personData);
    console.log('person creation result:' + JSON.stringify(personResponse));
    
    var updateData = {
      MainContact: personResponse.d.ID
    };
    
    var companyToUpdate = personData.Account;
    await updateCompany(updateData, companyToUpdate);
  }
  
  async function POSTrequest(requestType, requestData) {
    console.log('making post request');
    
    var apiEndpoint = 'https://start.exactonline.nl/api/v1/'+ companyDivision +'/crm/';
    if (requestType == 1) {
      apiEndpoint += 'Accounts';
    }
    if (requestType == 2) {
      apiEndpoint += 'Contacts';
    }
    
    var postResult;
    console.log(requestData);
    await fetch(apiEndpoint, {
      method: "POST",
      headers: {
        'Accept': 'application/json',
        'Authorization': 'Bearer ' + authToken,
        'Content-Type': 'application/json'
      },
      body: JSON.stringify(requestData)
    }).then(response => {
      return response.json();
    }).then(jsonData => {
      postResult = jsonData;
    }).catch(error => {
      console.log(error);
    });
    return postResult;
  }
  
  async function PUTrequest(requestType, requestData, recordId) {
    var updateEndpoint = 'https://start.exactonline.nl/api/v1/'+ companyDivision +'/crm/';
    
    if (requestType == 1) {
      updateEndpoint += "Accounts(guid'" + recordId + "')";
    }
    if (requestType == 2) {
      updateEndpoint += "Contacts(guid'" + recordId + "')";
    }
    
    await fetch(updateEndpoint, {
      method: 'PUT',
      headers: {
        'Content-Type': 'application/json',
        'Authorization': 'Bearer ' + authToken
      },
      body: JSON.stringify(requestData)
    });
  }
}

async function executeAction(){
  console.log("starting process");
  await processAction("create_company_and_contact");
  return ("process completed successfully");
};

output = [executeAction()]

Has anyone encountered similar issues with multiple API calls on these platforms? Any suggestions for making this work reliably?

This happens because automation platforms struggle with concurrent HTTP requests and promise resolution. You’re making multiple API calls without error handling, so they fail silently on platforms like Zapier. I’ve hit this exact issue with ExactOnline’s API.

The problem is your await pattern in those fetch calls - automation platforms timeout or drop connections when they can’t predict how long things will take. Wrap each API call in try-catch blocks and add explicit delays between requests with setTimeout.

That output array should return the actual result, not a promise wrapped in an array. Most importantly, validate response status before processing JSON since ExactOnline sometimes returns 200 status but puts error messages in the body.

zapier gets weird with async/await sometimes. switch to .then() chains - yeah, it’s messier but automation platforms handle promises way better. also, that output array looks suspicious. most platforms want single values, not arrays. ditch the brackets and return executeAction() directly.

Hit the same issue with n8n and similar platforms. These tools have execution timeouts and memory limits that don’t handle complex async workflows well. Your nested async functions in processAction create callback hell and memory leaks. I fixed it by flattening the execution flow and adding delays between API calls. Don’t chain everything - break it into separate steps with error handling at each one. Also check Zapier’s request limits per execution (usually 10-15 depending on your plan). A retry mechanism with exponential backoff saved me too since these platforms get flaky with external APIs. Your fetch code looks good, but add status code checking before processing responses.