Star

Created With

linkRequest Headers

Optionally specify a list of headers to be added to the request.



linkBasic Example

1linkconfiguration:

2link host: swapi.dev

3link scheme: https

4link base_path: /api

5linkspecs:

6link - request:

7link method: get

8link path: /films/1/

9link headers:

10link - name: Accept

11link value: application/json

12link - name: X-CustomHeader

13link value: some-value

14link response:

15link status_code: 200

See also: Example: Suite Using Headers



linkDynamically Set Headers

Dynamic headers can be added by setting headers as an object to the this.test context:

1linkconfiguration:

2link scheme: http

3link host: 127.0.0.1

4link port: 3027

5linkspecs:

6link - before_test:

7link run_type: inline

8link inline:

9link function: !!js/function >

10link function() {

11link this.test.headers = { header2: 'header2-value' };

12link }

13link request:

14link path: /echoHeaders

15link method: get

16link headers:

17link - name: header1

18link value: header1-value

19link response:

20link json_data:

21link - path: "$.header2"

22link value: "header2-value"

23link - path: "$.header1"

24link value: "header1-value"

See also: Overview of Hooks



Request HeadersBasic ExampleDynamically Set Headers

Home

Getting Startedchevron_right
Basicschevron_right
Requestchevron_right

Request Basics Headers Cookies Query Parameters Path Parameters

Payload Bodychevron_right

File Uploads Auto-Retry Additional Options

Response Validationchevron_right

Overview

Assertionschevron_right

Status Code Headers & Cookies

Bodychevron_right
Hooks & JSchevron_right

Overview

Function Typeschevron_right
Suite-Level Hookschevron_right
Spec-Level Hookschevron_right
Contextchevron_right
DRY & Reusing Specschevron_right
Command Line Interface (CLI)chevron_right