The most convenient way to test and debug webhooks

The most convenient way to test and debug webhooks

2021-06-22

QuickMocker is a stub API tool with ability to provide mock data depending on the HTTP request URL and method. In other words this is a test doubles tool. In addition to this there are plenty of other nice features like RegExp URL, multiple HTTP methods, endpoint prioritization, shortcodes for response templating, API proxy, restrictions etc. 

In this article we are going to talk more about the unique feature that allows not only capturing and intercepting any HTTP request made to your stub API, but also forwarding it to any other HTTP URL including your localhost. 

But what’s the point of forwarding the request to your local environment? Well, you probably won’t need it in many cases especially if your app does not communicate with other 3rd parties. Actually it might even interact with other APIs, but only by sending the remote requests on its own. Still, what would you do if your localhost app needs to capture a request back from that other API or 3rd party? Most likely your local environment app is not exposed to the public network and therefore receiving requests from somewhere else would be troublesome. You might want to change the network isolation level of your app by pushing it to some different environment which can have a public DNS / IP. Or maybe adding a router forwarding to some TCP/IP port on your computer? Yeah, this can work. But it is not the most convenient way of the reverse interaction with “the world” during the stage of application development on your local machine. By the way, in case you do not know, this reverse approach of communication is called webhooks. We create hooks (webhooks) in our app that should capture the requests from other parties.

Anyway, if the options of reverse communication or webhooks provided above are not convenient, which would be? That’s exactly where QuickMocker and its local forwarder comes in handy.

First of all, QuickMocker provides a public domain for your dummy API reachable from anywhere and a requests log for all the stub collections. Thus, any request made to these stub endpoints will be intercepted and can be debugged later. But QuickMocker is not only capable of capturing and debugging the requests. It allows you to forward them to other URLs including URLs of the apps that are hosted locally on your computer. What is even better, you may forward any intercepted request not only automatically in real time, but also on demand any time you want after the request interception occurred and you can repeat this request forwarding over and over again or as many times as you need. In case your local URL has changed for any reason or maybe there are multiple endpoints that should receive the same webhook notification, you can change the forwarder URL and run the requests again for the local debugging and testing purposes.

 

So, how do you do that? Very simply. First of all, register a free account if you do not have one yet, create a new project, switch to the Requests Log tab and from there set the Forwarder URL which should point to the base URL of your localhost application. There could be some extra steps involved in case you are using HTTP protocol instead of HTTPS within your local app or for instance in case your local app does not handle a preflight request. You may read a distinctive description on those extra steps on our FAQ page, particularly inside the “How do I test webhooks with Local Forwarder?” section.

Stay tuned and as usual happy API mocking!