Best answer

Zapier webhook - How to recieve data from custom code

  • 29 September 2020
  • 3 replies
  • 859 views

Userlevel 1

Hi all,

 

So i’m trying to send data from my website to a zapier webhook using my own code. I’m trying to do it in pure javascript but i cant seem to pick the sent data up, if it’s sending at all.

 

Here’s my example:

var request = new XMLHttpRequest();

var webhookURL = "https://hooks.zapier.com/hooks/catch/11111/ttttttttt/";

var data = {

download: event.data.download,

upload: event.data.upload,

};

request.open("POST", webhookURL, true);

request.setRequestHeader('Content-type', 'application/json; charset=UTF-8"');

request.send(JSON.stringify(data));

 

 

I’m not sure if this is the kind of thing that anyone here could help me but i’d thought it would be worth a shot.

 

Thanks.

icon

Best answer by CoolGuy 2 October 2020, 00:39

View original

This post has been closed for comments. Please create a new post if you need help or have a question about this topic.

3 replies

Userlevel 7
Badge +10

@CoolGuy In situations like this there are many variables, so I try to take out one of the variables, I would recommend taking out Zapier and swapping it to a Webhook Testing site like https://webhook.site/ send the POST to there which will allow you to inspect it and verify that indeed your script is sending out the information and that it’s being received correctly by the resulting server/webhook URL. 

 

Based on that, if it works perfectly (send a screenshot of the out put from Webhook.site and then we can look into what might be wrong over at Zapier on the webhook receiving trigger step.

Userlevel 1

For anyone wondering I actually managed to get it working.

Using this:

 

var request = new XMLHttpRequest();

var webhookURL = " ";

 

var data = {

"name" : name

};

request.open("POST", webhookURL, true);

request.setRequestHeader('Content-type','application/x-www-form-urlencoded');

request.send(JSON.stringify( data ));

I tried implementing this and seems like it only hits the webhook every few tries. Any ideas why that might be?