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?