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?