Dec 05, 2021 06:57 AM
Hi everyone,
I’m executing a post request via the customer script app pointing to an integromat webhook to trigger an automation. The integromat scenario takes a while to run (approx. 45 seconds), as it duplicates heavy Google Slides presentations.
The scenario ends by a the simple webhook response such as this one:
{
"body": {"message":"Scenario successful."},
"status":200
}
I’m receiving the following error:
Unexpected token A in JSON at position 0
This would normally indicate that the JSON string is malformatted and can’t be parsed. But a few tests, it looks like the await response.json() line is executed before the response is actually returned from integromat (it waits ~40seconds for a response before moving on).
I have tested a mock scenario (running in a few seconds) returning the same json string and it works just fine.
According to the researches I’ve made, default fetch()
requests timeout at the time indicated by the browser which would be 300 seconds in Chrome, but I’m wondering if there is any extra limitation coming from the scripting block environment?
Here is the code I’m executing:
const options = {
method: 'POST',
headers: {
'Accept': 'application/json',
'Content-Type': 'application/json;charset=UTF-8'
},
body: body
};
var response = await fetch(url, options)
var data = await response.json();
Thanks a lot for your help!
Dec 05, 2021 07:23 AM
Welcome to the community, @xad9119!
I don’t know the direct answer to your question, but within your Integromat scenario, you can go into the scenario settings (button at the bottom of the screen) and check the checkbox for “auto commit”. This will immediately send your webhook response back to Airtable, without waiting for the entire Integromat scenario to finish processing.
Dec 07, 2021 09:35 AM
Hi @ScottWorld !
Thanks for your help. That’s indeed an interesting workaround that could work, but I guess that I’m still blocked if my script expects some information from the scenario to work properly?
Dec 07, 2021 11:14 AM
If that’s the case, then I would either perform al of those subsequent activities with Integromat, or send the information back to Airtable and then have a completely different Airtable automation process it from there.