For the complete documentation index, see llms.txt. This page is also available as Markdown.

Header value

This is a pre-built action available under @Assertion element type. This action checks whether the value of a specified header in the API response matches the expected value or regular expression pattern. The output variable stores the validation result as True or False.

Syntax

Input Value: <Header name>;<Header value>;<Match type>

Note: The match type must be either Equals or Regex.

Argument
Description

<Header name>

(Required)

Enter the exact name of the response header whose value you want to check.

<Header value>

(Required)

Enter the expected header value or the regular expression pattern to use for checking the header value.

<Match type>

(Required)

Specify how the header value should be checked.

  • Equals checks whether the actual header value exactly matches the expected value.

  • Regex checks whether the header value matches the specified regular expression pattern.

Output Value: <Actual header value (optional)>;<Keyword status (optional)>

Argument
Description

<Actual header value> (Optional)

The output variable stores the actual value of the specified header returned in the API response.

<Keyword status> (Optional)

The output variable stores the result of the check as True or False.

Example 1: Checking a Header Value

In this example, we explain how to verify that the value of the Content-Type header matches the expected value.

  • Action: Header value

  • Input Value: Content-Type;application/json;Equals

    • The first value Content-Type specifies the name of the response header to check.

    • The second value application/json specifies the expected value of the response header.

    • The third value Equals specifies that the actual header value must exactly match the expected value.

  • Output Value: {Actual Value};{Status}

    • The first output variable {Actual Value} stores the actual value as application/json.

    • The second output variable {Status} stores the execution result:

      • True: The actual header value matches the expected value.

      • False: The actual header value does not match the expected value.

  • Logical Explanation: The Header value action takes the header name Content-Type, expected value application/json, and match type Equals from the Input Value column. The action gets the actual value of the Content-Type header from the API response and compares it with the expected value. Since the actual value is application/json, the {Actual Value} variable stores application/json and the {Status} variable stores the result as True.

image

Example 2: Checking a Header Value Using Regex

In this example, we explain how to verify that the Server header value follows the expected format when the server version may change.

  • Action: Header value

  • Input Value: Server;nginx\/[0-9]+\.[0-9]+\.[0-9]+;Regex

    • The first value Server specifies the name of the response header to check.

    • The second value nginx/[0-9]+.[0-9]+.[0-9]+ specifies the regular expression pattern that the header value must match. The pattern checks that the value starts with nginx/ followed by a version number such as 1.20.1.

    • The third value Regex specifies that the actual header value should be checked against the regular expression pattern.

  • Output Value: {Actual Value};{Status}

    • The {Actual Value} variable stores the actual value returned for the Server header. In this example, it stores nginx/1.20.1.

    • The {Status} variable stores the result of the validation.

      • True: The actual header value matches the specified regular expression pattern.

      • False: The actual header value does not match the specified regular expression pattern.

  • Logical Explanation: The Header value action takes the header name Server, regular expression pattern nginx/[0-9]+.[0-9]+.[0-9]+, and match type Regex from the Input Value column. The Action gets the actual value of the Server header and checks it against the specified pattern. Since nginx/1.20.1 matches the pattern, the {Actual Value} variable stores nginx/1.20.1 and the {Status} variable stores the result as True.

image

Last updated