Skip to content

Validate API Response Format Command: RESPONSE_VALIDATE_STRUCTURE

The Validate API Response Format command checks whether a received JSON response matches an expected JSON structure. If the structures match, the result is stored as true in the specified variable. If there are differences, the variable will contain details of the mismatched elements.

Example: Suppose after making an API request, you receive the following JSON response:

scrn-example-get-data-from-json-using-key-command
Your expected JSON structure is:

scrn-example-expected-structure-validate-api-response-format-command

Steps to Configure:

  1. Select Validate API Response Format from the Action dropdown.
  2. Leave the Screen Name field blank.
  3. In the Element Key field, enter the variable name where the result will be stored (e.g., ValidationResult).
  4. In the Parameters section, enter the expected JSON structure to compare against the API response. For example:

{
  “user”: {
  “id”: “”,
  “name”: “”,
  “email”: “”
 }
}

  1. Click Save.

Note: While the steps for adding an action command are identical in both views, the display of the steps changes:

scrn-validate-api-response-format-command-tabular-view
Tabular View
scrn-validate-api-response-format-command-card-view
Card View

Example Workflow:

The following screenshot illustrates how the Validate API Response Format command is structured within an API test case in HuLoop.

scrn-example-workflow-validate-api-response-format
Workflow showing the Validate API Response Format step in an API automation sequence

Expected Outcome:

  • If the actual API response matches the expected structure, the variable ValidationResult will store true.
  • If there are missing or extra fields, ValidationResult will contain details of the mismatches.
  • This variable can be referenced using ${ValidationResult} in assertions or further validation steps.

Note: Ensure the expected JSON structure accurately represents the response format.

Back To Top