ExactOnline API multiple requests not working on automation platforms

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

Here’s a simplified version of my automation code:

const apiToken = 'your_api_token';
const companyId = 'your_company_id';

const customerInfo = {
  "Name": "Test Company",
  "City": "New York", 
  "Website": "example.com"
};

const personInfo = {
  "FirstName": "John",
  "LastName": "Smith",
  "City": "New York"
};

async function processData(operation) {
  if (operation === "create_customer_and_contact") {
    const customerId = await createCustomer(customerInfo);
    personInfo.Account = customerId;
    const contactId = await createContact(personInfo);
    return 'Process completed successfully';
  }
}

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

async function createContact(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/${companyId}/crm/`;
  apiUrl += requestType === 1 ? 'Accounts' : '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(data, customerId) {
  const updateUrl = `https://start.exactonline.nl/api/v1/${companyId}/crm/Accounts(guid'${customerId}')`;
  
  await fetch(updateUrl, {
    method: 'PUT',
    headers: {
      'Content-Type': 'application/json',
      'Authorization': `Bearer ${apiToken}`
    },
    body: JSON.stringify(data)
  });
}

async function main() {
  return await processData("create_customer_and_contact");
}

output = [main()];

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

Had the same issue with ExactOnline API when I switched from local testing to cloud automation. It’s probably how these platforms handle promise resolution and execution context differently. Your code looks fine, but automation platforms usually have tighter timeouts and handle async stuff differently than local Node.js. Try wrapping your main function differently and add error handling to see what’s actually breaking. Also check if your platform supports all the fetch API features you’re using - some limit certain headers or request methods. One more thing - verify your API token has the right permissions for external IP requests. ExactOnline sometimes acts weird depending on where the request comes from.

This sounds like an authentication or environment variable issue. I’ve hit this before - the API token either isn’t getting passed correctly or your platform’s security settings are blocking it. Check if your automation platform needs special config for external API calls or has IP restrictions you need to whitelist. ExactOnline’s API is also pretty picky about concurrent requests. Your code makes multiple calls back-to-back without checking if each one actually worked. If one fails silently, everything breaks. Add response status checks and console logging between each API call to see exactly where it’s dying. Also worth checking - some platforms have different timeout settings than your local environment.

you’re not awaiting main() properly. change output = [main()]; to output = [await main()]; - automation platforms handle async differently than local environments, so it’s probably stopping before your fetch calls run