Status code
This is a pre-built action available under @Assertion. This action validates the expected HTTP status code against the status code returned in the API response header. The dynamic variable stores the actual HTTP status code returned in the response header.
Note: An API request must be added and executed successfully before configuring or evaluating API Assertions.
Syntax
Input Value: <Status code expected value>
Status code expected value (Required)
Provide the status code which you want to validate.
Output Value: <Actual value>(optional);<Keyword Status>(optional)
Actual value (optional)
The actual value variable stores the actual status code returned.
Keyword Status (optional)
The keyword status variable stores the status as True or False.
Example: Validating Status Code of API Response
In this example, we explain how to verify that the API response returns the expected HTTP status code.
Action: Status code
Input Value: 200
The value (200) specifies the expected HTTP status code to validate.
Output Value: {actual_result};{keyword_status}
The first output variable {actual_result} stores the actual HTTP status code (200) returned by the API.
The second output variable {keyword_status} stores the verification result with the following possible values:
True: If the actual HTTP status code matches the expected status code.
False: If the actual HTTP status code does not match the expected status code.
Logical Explanation: The Status code action fetches the expected HTTP status code from the Input Value column (200) and compares it with the actual status code returned by the API response. The actual status code (200) is stored in the {actual_result} variable. If the {keyword_status} variable is defined, it stores True when the expected and actual status codes match or False when they do not match.

Last updated