> ## Documentation Index
> Fetch the complete documentation index at: https://docs.mobileboost.io/llms.txt
> Use this file to discover all available pages before exploring further.

# Network requests

> Make network requests before or during test execution

There are two ways to make network requests as part of a test:

1. Simple `GET` requests inline as a test step
2. `cURL` requests that run before the test starts (pre-requests)

## Inline GET requests

You can make a `GET` request directly in a test step and use the response data in subsequent steps.

### Example: retrieving an OTP code

Assuming there is an endpoint to retrieve an OTP code:

```
https://customer-api.com/fetch-otp?customer=...&apiKey=...
```

With a response like:

```json theme={null}
{
  "otp_code": "123456"
}
```

You can use the following test steps:

```
1. Perform a network request to https://customer-api.com/fetch-otp?customer={{env.username}}&apiKey={{env.api-token}} with the json selector 'otp_code'
2. Enter the remembered otp_code in the password field
```

Step 1 makes the request and remembers the `otp_code` from the response. Step 2 uses the extracted value by referencing it as "remembered". You can use environment variables (e.g. `{{env.username}}`) as part of the URL.

For more complex requests like `POST` or `DELETE` with payloads, use pre-requests instead.

## Pre-requests (cURL)

Pre-requests let you execute `cURL` commands before the test starts. This is useful for setup tasks like cleaning data, creating test accounts, or fetching credentials.

### Step 1: Define the cURL commands

Navigate to the **Settings** tab within your test. In the **Pre-requests** section, define one or more `cURL` commands that will be executed sequentially before the test runs.

Examples:

```bash theme={null}
# Delete order history before the test
curl -X DELETE "https://api.example.com/users/123/order-history" \
     -H "Authorization: Bearer {{env.apitoken}}"
```

```bash theme={null}
# Create a test user
curl -X POST "https://api.example.com/users/create" \
     -H "Content-Type: application/json" \
     -d '{"userType": "premium"}'
```

### Step 2: Define values to remember

If a pre-request returns values you want to use in the test, specify them using dot selector syntax. For example, given this response:

```json theme={null}
{
  "username": "generated_user_123",
  "password": "123456"
}
```

You can define `username` and `password` as values to remember in the pre-request settings.

### Step 3: Use remembered values in the test

Reference the remembered values in your test steps using the "remembered" keyword:

```
1. Tap on the username input field
2. Type the remembered username
3. Tap on the password input field
4. Type the remembered password
```
