# Request step

Request is the main building block of tests. It represents a single API call or a user action.

![](https://684333474-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LHDbUNdi3wPd9vSolzU%2Fuploads%2Fgit-blob-7cd1c05e02db0cbc3ae2fc74adf6b39be17f95e9%2FScreenshot%20-%202021-10-03T133534.753.png?alt=media\&token=8f2fab93-a902-46ae-a39d-3de433f89613)

## Request sections

When we expand the request editor by clicking<img src="https://684333474-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LHDbUNdi3wPd9vSolzU%2Fuploads%2Fgit-blob-f42735bfbac19abdbede0667da6f9fdaebc9e659%2FScreen%20Shot%202021-10-03%20at%2013.37.48.png?alt=media&#x26;token=65028128-a6bf-4e5b-9331-84d81e363b4d" alt="" data-size="line"> at the top-right of the request, we can see that a test request includes two main sections - **Request and Response Handling sections**.

![](https://684333474-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LHDbUNdi3wPd9vSolzU%2Fuploads%2Fgit-blob-924fe6f236ad6e567dfb5e0ce87fc1555151e0dd%2FScreenshot%20-%202021-10-03T134902.806.png?alt=media)

![](https://684333474-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LHDbUNdi3wPd9vSolzU%2Fuploads%2Fgit-blob-085cdf783b304e78d09f0bd903ad4478d505afe1%2FScreenshot%20-%202021-10-03T134210.876.png?alt=media\&token=71e4e35a-a6f2-468e-a2f1-a0409c49b5af)

### The Request Handling section

![The request handling section](https://684333474-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LHDbUNdi3wPd9vSolzU%2Fuploads%2Fgit-blob-46b4f16895a341a21ffbc818ed3973a070e1d620%2FScreenshot%20-%202021-10-03T135227.782.png?alt=media\&token=444f38c0-ce12-4fd7-aa1b-6d0d95ca76cc)

* The **Method** and **URL** fields are the most basic requirements for a valid request.
* Black input fields are fields in which you can use [parameters](https://docs.loadmill.com/api-testing/test-suite-editor/parameters) and [functions](https://docs.loadmill.com/api-testing/test-suite-editor/parameters/functions).
* It is recommended to set the Request description in a way that describes its action. This will make it easier for you to debug your tests later if this request fails.
* Some requests require a **body**. Selecting the right **content-type** for your request will help us highlight the syntax of your request body (i.e. JSON or XML).
* The **Headers** section allows to see and set the request headers. You can add header to all requests or as a Global Header so that it will be added to all of the test flow requests and appear in [the Global Login tab](https://docs.loadmill.com/api-testing/test-suite-editor/global-login-flow).

#### GraphQL requests

A standard GraphQL POST request should use the `application/json` content type, and include a JSON-encoded body of the following form:

```json
{
    "query": "...",
    "operationName": "...",
    "variables": {
        "var1": "value",
    }
}
```

`operationName` and `variables` are optional fields. `operationName` is only required if multiple operations are present in the query.

The response should return the queried data in a JSON. i.e.,

```json
{
  "data": { ... },
  "errors": [ ... ]
}
```

Based on ([graphql.org](https://graphql.org/learn/serving-over-http/)).

### The Response Handling section

![](https://684333474-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LHDbUNdi3wPd9vSolzU%2Fuploads%2Fgit-blob-04553afc1204d649a0025183728c93c8eb449e26%2FScreenshot%20-%202021-10-03T135800.939.png?alt=media\&token=fe9378da-de46-434d-be12-ba53a6fd67f9)

![The response handling section](https://684333474-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LHDbUNdi3wPd9vSolzU%2Fuploads%2Fgit-blob-65e82ff219a8265937c9528f751676126455a41f%2FScreenshot%20-%202021-10-03T135823.525.png?alt=media\&token=969b0497-4432-4a66-bfed-c234319ba295)

The response handling section includes 3 sections: [**Extractions - Set Parameters**](https://docs.loadmill.com/api-testing/test-suite-editor/set-parameters-extractions), [**Postscript - run code**](https://docs.loadmill.com/api-testing/test-suite-editor/postscript-run-code) (disabled by default), [**Assertions - Verify Response**](https://docs.loadmill.com/api-testing/test-suite-editor/assertions) and Flow control.

#### The **Extractions - Set Parameters** section allows you:

* To extract values from the response body into an existing or a new parameter using JSONPath, Closure, jQuery, RegExp.
* To extract an HTTP header value into a parameter using the Header extractor.
* To assign a static value or [**apply a function on another parameter**](https://docs.loadmill.com/api-testing/test-suite-editor/functions) using the "Assign" option.
* To add an extraction from [the Suggestions repository](https://docs.loadmill.com/api-testing/test-suite-editor/set-parameters-extractions#suggestions). Team admins configure the repository within Settings - Suggestions.

![](https://684333474-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LHDbUNdi3wPd9vSolzU%2Fuploads%2Fgit-blob-d4b4e3c2b309b4cc3a5626fa49831f164f3d8dc1%2FScreenshot%20-%202021-10-03T140454.279.png?alt=media\&token=13fe5789-66b8-451e-8c77-6bed8047b1e7)

The **Assertions - Verify Response** section allows you to validate the request response.

![](https://684333474-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LHDbUNdi3wPd9vSolzU%2Fuploads%2Fgit-blob-e08a74243e33b0df9adb67b417172f0fd42b5b7a%2FScreenshot%20-%202021-10-03T140553.892.png?alt=media\&token=ecd1ef3a-343a-4754-b1eb-c510aa044432)

The **Flow Control** section allows to repeat the request until the parameter's value meets the requirement or number of iteration reached:

![](https://684333474-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LHDbUNdi3wPd9vSolzU%2Fuploads%2Fgit-blob-0654bd53f5371fa2ae03be8f5b8f74d6b2e1dd64%2FScreenshot%20-%202021-10-03T141405.887.png?alt=media\&token=0dfcf583-bcce-4359-a318-a66bddd4f2e6)

You can also set Skip and Stop conditions between requests within this section:

![](https://684333474-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LHDbUNdi3wPd9vSolzU%2Fuploads%2Fgit-blob-616a28879a104e635bed41a203dae9759140b09c%2FScreenshot%20-%202021-10-03T141529.056.png?alt=media\&token=c956e898-ca2d-428d-90e0-b1aa7c3819c8)
