Test webhook simply and locally

There are many definitions of what webhooks are. Personally I like this one most: a webhook is an event notification sent over HTTP, the same protocol used for providing any web page data. Typically sent using POST method, which contains information that is supposed to be delivered to a specific URL. This URL is our hook (webhook) that captures or intercepts the data.

If you are still reading this paragraph, then you are the “right” person. No point telling you that debugging and testing webhooks is not the easiest thing while you are developing your application. First of all it requires you to get the notification from the 3rd party somehow, do some boring sequence of steps in order to receive the request. But the main thing is that you need to intercept this request somehow. Doing it while your app is still on the local environment might not be the easiest thing. Luckily there are multiple online mock servers that have a publicly accessible address and you can temporarily feed its URL to the 3rd party that will send the HTTP callback. Such services are also called fake API or API mocking services.

Some of those services allow not only intercepting and debugging the data that arrives from the 3rd party, but it can also be like a proxy that can forward the captured request to your local application. This is especially handy in terms of not only debugging, but also performing webhook tests including end-to-end tests. Still, all of the online mock servers that support requests forwarding to your local app require you to install some additional software. Currently only one mocking tool called QuickMocker does not need any additional programs to be installed on your machine. All you need to perform your webhook test is a browser. Because the request forwarding works through the browser, you might require some additional configuration like allowing non-HTTPS requests from the mock server domain in case your local app is using non secure HTTP protocol. Additionally CORS will need to be enabled on the level of your local web server or local app… if that’s a problem for some reason, there are multiple chrome extensions like Moesif Origin & CORS Changer, Unblock CORS etc. that allow you to disable CORS on the specific tab. Such extension might be useful not only for webhooks testing, but for many other development purposes by the way. Another cool and interesting thing about forwarding requests from QuickMocker is that it remembers the data sent by the 3rd party and it can re-forward it again whenever you need. You do not have to go through the boring sequence of steps in order to initiate or trigger the HTTP-callback from the 3rd party anymore. If that sounds interesting, then head over to QuickMocker and try it out yourself.

Washim

Washim is an Bangladeshi tech based web blogger. Right now he writes for techshim.com excellent content Android Apps, Games and much more.

Related Articles

Leave a Reply

Back to top button