You might want to not only confirm that an API response code is expected but that the right data comes back in the right format when doing the following:
In order to execute this procedure in your environment, the following data, services, or apps are required:
When a Splunk user hits the endpoint for their check with an API key, you want to make sure that a “200 OK” response code is returned, along with the data set for the correct ID that matches the endpoint. To validate this, create an external, synthetic test to hit the check endpoint at a set frequency from multiple locations.
- Make a request with an API key to Splunk API’s endpoint for real browser check data.
- Assert that the response code contains the value ‘200.’
- Extract the check ID from the JSON using JSON path.
- Assert that the check ID extracted from the JSON path is the expected value.
This simple user flow helps test:
- Availability: The check will fail if the API returns a response code that’s not 200 OK.
- Data Format: If the data comes back from the API in a format other than JSON then the step to extract a value using JSON path will fail the check.
- Data Quality: If you’re able to extract a value for the ID but it doesn’t match the expected value, then the assert step will fail the check.