Webhooks send information from your application or server to the specified URL.
Unlike APIs, webhooks do not wait for your request. Instead, they wait for a specific event on the server and send the request themselves.
Webhooks send information as an HTTP POST request that can contain any required content. Most webhooks use the application/json
content type.
ReadyAPI can catch requests from webhooks by using VirtResponse test steps. Use the REST VirtResponse or the SOAP VirtResponse test step and configure it to receive a request from a webhook.
You can also use assertions to analyze a request and see if your webhook sends the correct message.
You can use ReadyAPI to work with any webhooks. In this example, we will use GitHub Webhooks.
Note
You will need a GitHub account to complete this tutorial.
Create a webhook. To learn how to do that, see the Creating Webhooks page.
Use ngrok to make your localhost available on the Internet.
Run ngrok using the following command:
ngrok http 4567
Find the Forwarding line. It should look like this:
Forwarding http://8a6f5e6e.ngrok.io -> localhost:4567
Copy the
ngrok.io
URL as a new Payload URL.Open ReadyAPI and create a new project by using this URL:
http://localhost:4567/payload
Create a REST VirtResponse test step with the service you created at port 4567:
Set a POST request method for the VirtResponse.
Set the Timeout property to a large value (for example, 1000000) and start the test case.
After configuring the VirtResponse, push a commit to the repository you are using.
The GitHub webhook will send a REST request containing commit information to your URL, and ReadyAPI will catch it. You can see it in the REST VirtResponse editor.