Applies to ReadyAPI 2.7, last modified on May 14, 2019

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.

Testing Webhooks With ReadyAPI

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.

Catching Webhook Messages – Example

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.

  1. Create a webhook. To learn how to do that, see the Creating Webhooks page.

  2. Use ngrok to make your localhost available on the Internet.

  3. Run ngrok using the following command:

    ngrok http 4567

  4. Find the Forwarding line. It should look like this:

    Forwarding http://8a6f5e6e.ngrok.io -> localhost:4567

  5. Copy the ngrok.io URL as a new Payload URL.

    GitHub: Entering a payload URL
  6. Open ReadyAPI and create a new project by using this URL:

    http://localhost:4567/payload

  7. Create a REST VirtResponse test step with the service you created at port 4567:

    ReadyAPI: Creating a new REST VirtResponse step
  8. Set a POST request method for the VirtResponse.

    ReadyAPI: Changing a REST method
  9. 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.

Highlight search results