Best answer

Rest Hook - get error code back

  • 26 October 2020
  • 4 replies
  • 292 views

I am using the Rest Hooks and everything works great - get the hookUrl, post the data to the hookUrl, and my Zap successfully runs.

 

However, if I send bad data to the hookUrl an error correctly occurs. Is there a way to retrieve or be informed (a webhook?) that a task error occurred? I believe the call to the hookUrl is asynchronous, so the response will never contain an error.

 

Thank you for the guidance.

icon

Best answer by Liz_Roberts 5 January 2021, 15:59

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.

4 replies

Userlevel 7
Badge +14

Please provide screenshots how how your Zap step is configured using the hooks.

Userlevel 7
Badge +14

Try Zapier Manager app: https://zapier.com/apps/zapier-manager/integrations#triggers-and-actions

 

Thank you Troy. This is an interesting zap to get errors. Users are creating Zaps based on my App, so I would like to see if any errors occurred at the App level.

 

So my Rest Hook has a subscription:

const options = {
url: url,
method: 'POST',
headers: {
'Content-Type': 'application/json',
'Accept': 'application/json',
'Authorization': `Bearer ${ bundle.authData.API_KEY}`
},
params: {
'API_KEY': bundle.authData.API_KEY
},
body: {
'hookUrl': bundle.targetUrl
}
}

return z.request(options)
.then((response) => {
response.throwForStatus();
const results = response.json;

// You can do any parsing you need for results here before returning them

return results;
});

When a new Zap is turned on I get back the hookUrl and post to it when I need to activate the Zap on behalf of a user.

 

fetch(hookUrl, options)
.then((res) => res.json())
.then((json) => {
console.log(json);
return { status: "success" };
})
.catch(el);

The return for the POST always is success (assume because Zap is going to run later). If the Zap fails, my app has no way to know.

 

Is there any means to query the status of the Rest Hook to see if actual success or failure?

Userlevel 7
Badge +8

Hi @helmar ,

I see you were in touch with Krishna in Support on this! Sharing their response below in an effort to assist other members who may have a similar question: 

 

“There isn't a way to know if the Zap hit an error through the API. The hook URLs respond with a success always to keep our infra highly available. Due to this, most times during an incident we are also able to recover and run subscription hooks that we received during the outage.That said, you can always look in your monitoring tab for any errors on your app for the last 7 days.

You could also write Support with a link to the Zap and we can take a look for you. When something wrong is happening with an app, users write to us and we create a bug report that is available to you on the developer platform. This way it is unlikely that you would miss any incidents with the app.”