Best answer

Webhook response handling

  • 6 April 2023
  • 9 replies
  • 1006 views

Userlevel 1

Hello, I’m using webhooks by zapier to push invoices in Xero from my custom erp system.

I need some kind of acknowledgment in my system that the invoice has been pushed successfully in order to mark it as ‘synced’. I sent some wrong data on purpose and got a 200 response code as I was expecting according to your documentation however parsing the  response content all I can get is 

{"attempt":"01875616-eb6d-9e7b-ff2c-29181e97cb38","id":"01875616-eb6d-9e7b-ff2c-29181e97cb38","request_id":"01875616-eb6d-9e7b-ff2c-29181e97cb38","status":"success"}

Can you advise on how to use this information for debugging?

I can see the error details for each run on the platform and in the error notification emails but I was hoping to catch these and take action within my system after the zap completes. Is there a way to do so?

icon

Best answer by Troy Tessalone 12 April 2023, 17:13

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.

9 replies

Userlevel 7
Badge +14

Hi @gusmaster 

Good question.

For us to have a better understanding of the data you are sending and receiving, please post detailed screenshots of an example, thanks.

Userlevel 1

Hi @Troy Tessalone,

thanks for your reply, so for example I posted an invoice in xero with an invalid email address, xero returned a validation error which is showed under that specific run in the zaps history. This step is triggered by a zapier webhook which is called from my code through an http client (I’m using c# but the language should be irrelevant). Now when I catch the response in my code I’m getting 200 and that criptyc content rather than the below validation error which would be useful to determine if the zap completed successfully or failed.

In this case it failed but the only way to know this is via the notification emails or looking in the zaps history.

 

Userlevel 7
Badge +14

@gusmaster 

The Xero response indicates the email value is invalid.

We can’t see the email address value, but it looks very long for an email address.

Make sure a valid email address format is being used and is not a dummy email address.

 

Userlevel 1

I think I’ve been misunderstood. The invalid email was sent on purpose to see the response I get back when the zap fails. I’m triggering the zap from this code which basically posts the json payload to a zapier webhook. I understand zapier webhooks will always return 200 regardless so I’m asking what is the meaning of the reponse below and if it can be used to determine the real zap result. Maybe querying a zapier endpoint with request id?

 

using (var httpClient = new HttpClient())
{
                    string jsonData = JsonConvert.SerializeObject(invoices);
                    StringContent httpContent = new StringContent(jsonData, System.Text.Encoding.UTF8, "application/json");
                    HttpResponseMessage response = httpClient.PostAsync(trigger.Url, httpContent).Result;
                    if (response.IsSuccessStatusCode)
                    {
                        // NOTE:  Zapier always return 200 and this reponse instead of the email validation error
                        {"attempt":"01875616-eb6d-9e7b-ff2c-29181e97cb38","id":"01875616-eb6d-9e7b-ff2c-                 29181e97cb38","request_id":"01875616-eb6d-9e7b-ff2c-29181e97cb38","status":"success"}
                    }
                }

Userlevel 7
Badge +14

Hi @gusmaster 

There is no Zap API endpoint available to query to get the results of the Zap Run from the returned response for the Webhook.

{"attempt":"01875616-eb6d-9e7b-ff2c-29181e97cb38",
"id":"01875616-eb6d-9e7b-ff2c-29181e97cb38",
"request_id":"01875616-eb6d-9e7b-ff2c-29181e97cb38",
"status":"success"}

 

Userlevel 1

Ok I understand, it was worth asking anyway.

I think it would be extremely useful to be able to retrieve the real zap run result (and possibly the reason) from the webhook response. Getting always a success even when it’s not feels a bit illogical.

Thanks for the support.

Userlevel 7
Badge +14

@gusmaster 

Feedback and feature requests can be submitted by opening a ticket with Zapier Support to make sure it is properly logged: https://zapier.com/app/get-help

Userlevel 7
Badge +14

@gusmaster 

The Webhook being received was a success which is why you get the 200 response from the Zap Run trigger step.

How the other steps in the Zap Run play out is different.

You can see those in your Zap Run history: https://zapier.com/app/history/

 

For example the Zap Run could be designed to take minutes to days to complete running, so it’s unrealistic to expect to be able to keep the connection open for that long to return a response of the full Zap Run outcome.

Userlevel 1

I was suspecting that and I completely understand you can’t keep the connection open indefintely.

However you are already logging all the zap runs results and the reasons they failed so being able to retrieve these results via an API passing one of the ids in the response seems a reasonable feature. I’ll make sure to submit the request to the support. Thanks.