ExactOnline API multiple requests working locally but failing on automation platforms

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

Here’s my current implementation:

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

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

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

async function processWorkflow(workflowType) {
  if (workflowType == "create_business_and_contact") {
    const businessResult = await createBusiness(businessData);
    const businessID = businessResult;
    
    personData.Account = businessID;
    const contactResult = await createPerson(personData);
    
    return 'workflow completed';
  }

  async function createBusiness(data) {
    const response = await sendRequest(1, data);
    return response.d.ID;
  }

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

  async function sendRequest(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 modifyBusiness(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 executeWorkflow() {
  await processWorkflow("create_business_and_contact");
  return "execution finished";
}

output = [executeWorkflow()];

Any ideas why this might be happening on these platforms but not locally?

Your nested function declarations inside processWorkflow are probably the culprit. Automation platforms handle scope weird compared to local environments, so those nested functions might not be accessible when they actually run. Move createBusiness, createPerson, modifyBusiness, and sendRequest outside processWorkflow to global scope. I hit the same issue with Zapier - nested async functions would just silently fail. Also double-check if your platform supports all the ES6 features you’re using. Some still have spotty async/await support in certain contexts.

Same issue here with ExactOnline API on automation platforms. It’s probably a timeout problem - these platforms have tighter execution limits than running locally. Your three sequential calls (create business → create contact → update business) are likely taking too long together. Add try-catch blocks around each fetch request and see if you can bump up the platform’s timeout settings. Also throw in some retry logic since network connections on these platforms aren’t as stable as local testing.

sounds like a promise handling issue. automation platforms are stricter with async operations than local. make sure to await that executeWorkflow() call instead of just wrapping it in an array - that output line is likely the cause of the problem.