Page 1 of 1

Webhooks are not working

PostPosted: Wed Nov 16, 2022 5:53 pm
by sameermoin
Hi Everyone,

I enabled webhooks and subscribed for an event Inventory.Updated

Screenshot 2022-11-08 125147.jpg
Rest API Plugin


I subscribed for events:

2.jpg
Subscribed event


When I am trying to get the list of message responses I am getting nothing:

3.jpg
subscriber responses

Re: Webhooks are not working  Topic is solved

PostPosted: Wed Nov 16, 2022 6:06 pm
by Mike.Sheen
sameermoin wrote:Hi Everyone,

I enabled webhooks and subscribed for an event Inventory.Updated


Not a hell of a lot to go with here.

You need to make sure the WebHooksHostURL is reachable from the clients. This URL needs to be the URL of the Jiwa API.

A common mistake is to put http://localhost - which will work only from instances of Jiwa on the same machine as the API is running.

Another common mistake is using the public external DNS name without the correct hosts file entries or DNS records in place. One must be mindful of the network architecture and firewalls.

A simple test is to try putting the contents of the WebHooksHostURL into a browser on all machines expected to trigger a webhook - if it shows the Jiwa API metadata page, then that means it is reachable and should work.

Another place to look is in the SY_WebhookMessage and SY_WebhookMessageResponse tables. Using the API to look as you are won't reveal problems where the client could not reach the API to send the webhook in the first place - however, clients will fail over into an insert of these tables and will have messages in there the API won't know about until you restart the service.

From the screenshots you've provided my money is your WebHooksHostURL is not set correctly.

EDIT: I see I responded before you had added more information to your post.

Re: Webhooks are not working

PostPosted: Wed Nov 16, 2022 6:08 pm
by sameermoin
I tested my URL via postman and it's working. Even I also tried webhook.site for dummy requests and that one also not working.

Does it create any logs if the response is failed ?

Re: Webhooks are not working

PostPosted: Wed Nov 16, 2022 6:10 pm
by Mike.Sheen
sameermoin wrote:I tested my URL via postman and it's working. Even I also tried webhook.site for dummy requests and that one also not working.


I don't think you're hearing what I've been saying.

if you copy paste the URL you configured in the WebhooksHostURL into a browser, what do you see? Is it the Jiwa API metadata page? If not, then you're doing it wrong.

Re: Webhooks are not working

PostPosted: Wed Nov 16, 2022 6:22 pm
by sameermoin
yes it's taking me to metadata

4.jpg
metadata page

Re: Webhooks are not working

PostPosted: Wed Nov 16, 2022 6:26 pm
by Mike.Sheen
sameermoin wrote:Does it create any logs if the response is failed ?


Which response?

If you mean the client talking to the API to signal a potential webhook event, if there is an exception there it inserts into the SY_WebhookMessage with a not sent status - it's tried to inform the API of an event it might want to send to subscribers, but it was not able to service the request so it is put into the SY_WebhookMessage table for it to pick up the next time the service starts.

Check that table contents. If you have entries in there which are not sent, then you either have the WebHooksHostURL wrong, or it's not reachable by the clients.

If you mean the response the API gets from the webhook subscribers, then that goes into the SY_WebhookMessageResponse table.

Re: Webhooks are not working

PostPosted: Wed Nov 16, 2022 6:28 pm
by Mike.Sheen
sameermoin wrote:yes it's taking me to metadata

4.jpg


You have an awfully long URL in your WebhooksHostURL. I also notice it is HTTPS - make sure you have valid certificates for it - do you have valid SSL certs for your WebhooksHostURL?

Re: Webhooks are not working

PostPosted: Wed Nov 16, 2022 6:34 pm
by Mike.Sheen
And remember - if you make any changes to the system settings relating to the REST API, you need to restart that service before they have any effect.

Re: Webhooks are not working

PostPosted: Thu Nov 17, 2022 4:36 pm
by sameermoin
Hi Mike,

Thanks for your help finally it's working. I still don't know what the issue is. Actually, I am using ngrok to make my localhost URL publically accessible. I updated the firewall settings for the port on which Jiwa API is running.