How to Submit a Request to Rest Web API
The REST Web API task supports different HTTP methods that can be used according to your monitoring goals. Selecting a GET request will simply retrieve data from your Web API. Although request parameters can be included in the URL, it is recommended to use dedicated methods to push payload to an API.
To send any custom information, change data, or trigger any flow or event, use requests types as POST, PUT, or PATCH. In this case, to specify the request body, navigate to the Post Data section.
If your API requires authentication, provide the credentials in the Basic Authentication section. If token-based authentication is the method used, follow the recommendations provided for OAuth 2.0-based APIs and configure authentication parameters in a similar way.
In this section you can easily provide any request entities, such as JSON.
To specify the request body, just paste or enter JSON content into the field. The system will automatically parse the code and you’ ‘ll be prompted to select a content type header based on the request body type. Also, you can provide a custom content type header if it’s necessary.
Once specified, the content type will be automatically added to the Headers section.
In general, it is not enough to simply make a call to an API, the purpose to make sure the API response contains data that was expected to receive. To verify the API response, it is sufficient to find some keywords which match exactly in the response. Knowing your API response content, you can provide the keywords in the Content Validation section. For details, see the Keyword article.
Let’s consider an email REST API as an example. To monitor the service, we need to send the POST request to the corresponding API endpoint, along with the email details in the request body. To do this, we have to provide the endpoint URL and select the POST request type.
Since the email REST API requires basic authentication, we also need to provide the credentials in the corresponding section.
In the Post Data section, we will specify the JSON array with email details and select the header type to push payload to the API endpoint.
The next step is to specify a keyword to look for in the API response for its validation.