Save the date! Join us on October 16 for our Product Ops launch event. Register here.
Aug 24, 2020 04:24 AM
Using the new automations feature, I am trying to trigger an Integromat webhook when a new record enters a view.
However even though I have configured an input variable, and it is processing just fine, it won’t parse into the webhook URL.
I’ve attached some screenshots which hopefully explain what I mean.
The code I’m using is:
let data = input.config();
let response = await fetch('WEBHOOKURL?id=${data.ID}');
console.log(await response.text());
The test output shows the variable is picked up:
However the webhook receives only the code:
Would love some help - I’m sure I’m missing something very simple here…
Solved! Go to Solution.
Aug 24, 2020 10:21 AM
@Liz_Pulo and @Bill.French
Unless my eyes deceive me, I think the problem is pretty simple…
You have single-quotes surrounding your string, into which you are trying to interpolate a variable. In JavaScript, you have to surround your string in back-ticks in order for it to process interpolated variables.
So you need to replace:
let response = await fetch('WEBHOOKURL?id=${data.ID}');
with:
let response = await fetch(`WEBHOOKURL?id=${data.ID}`);
(notice how even this forum’s code-block text-formatting convention recognized a difference between how the two should be interpreted)
https://www.tutorialspoint.com/how-to-do-string-interpolation-in-javascript
Aug 24, 2020 09:56 AM
Hi Liz, and welcome to the community!
I would test more precisely the actual URL being used to call the webhook. In fact, consider creating the URL as a variable and then inspect that variable for proper formatting with the parameter embedded. I have a hunch it is not what you think it is, or … the webhook itself is not parsing the value as you expect it should.
Aug 24, 2020 10:21 AM
@Liz_Pulo and @Bill.French
Unless my eyes deceive me, I think the problem is pretty simple…
You have single-quotes surrounding your string, into which you are trying to interpolate a variable. In JavaScript, you have to surround your string in back-ticks in order for it to process interpolated variables.
So you need to replace:
let response = await fetch('WEBHOOKURL?id=${data.ID}');
with:
let response = await fetch(`WEBHOOKURL?id=${data.ID}`);
(notice how even this forum’s code-block text-formatting convention recognized a difference between how the two should be interpreted)
https://www.tutorialspoint.com/how-to-do-string-interpolation-in-javascript
Aug 24, 2020 04:05 PM
That is exactly it… thank you Jeremy!!! It’s now working :slightly_smiling_face: