Skip to content

Define Api Request Header Command: REQ_HEADER

The Define Api Request Header command is used to set a header for API service requests. This command allows you to include essential key-value pairs in the header, such as authorization tokens or content types, which are required for successful API communication.

Example: Suppose you need to include an Authorization token as a header to access a secured API endpoint. The header key is Authorization, and the corresponding value is Bearerabc123token.

Steps to Configure:

  1. Open the Case where you need to use this command.
  2. Add a new step at the required index.
  3. From the Action dropdown, select Define Api Request Header.
  4. In the Element Key field, specify the header key (e.g., Authorization).
  5. In the Parameters section, enter the corresponding value for the header key (e.g., Bearer abc123token).
  6. Click Save to complete the setup.

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

scrn-define-api-request-header-command-tabular-view
Tabular View
scrn-define-api-request-header-command-card-view
Card View

Notes:

  • You should define all headers between Start Api Request and End The Api Call commands.
  • It is recommended to define headers after Define Api Request Resource command to ensure the request is properly structured.

Example Workflow:

The following screenshot illustrates how the Define Api Request Header command is structured within an API test case in HuLoop.

scrn-example-workflow-define-api-request-header
Workflow showing the Defined API Request Header step in an API automation sequence

Expected Outcome on execution:

  • The specified header is successfully added to the API request.
  • This ensures that the API request is sent with the required key-value pairs, facilitating accurate communication and testing of the API service.
  • The headers can be validated or referenced in subsequent steps as needed.

Back To Top