Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion docs.json
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,9 @@
"general/api-client/rq-api-reference/rq-collection-variables",
"general/api-client/rq-api-reference/rq-globals",
"general/api-client/rq-api-reference/rq-test",
"general/api-client/rq-api-reference/rq-expect"
"general/api-client/rq-api-reference/rq-expect",
"general/api-client/rq-api-reference/rq-info",
"general/api-client/rq-api-reference/rq-iteration-data"
]
},
{
Expand Down
25 changes: 24 additions & 1 deletion general/api-client/collection-runner-data-file.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@
label: "Run Collections with Custom Data"
slug: "collection-runner-data-file"
visibility: "PUBLIC"
seotitle: "Run Collections with Custom Data - Requestly"

Check warning on line 6 in general/api-client/collection-runner-data-file.mdx

View check run for this annotation

Mintlify / Mintlify Validation (requestly) - vale-spellcheck

general/api-client/collection-runner-data-file.mdx#L6

Did you really mean 'Requestly'?
description: "Learn how to use CSV or JSON data files with the Requestly Collection Runner to iterate requests with multiple input values."

Check warning on line 7 in general/api-client/collection-runner-data-file.mdx

View check run for this annotation

Mintlify / Mintlify Validation (requestly) - vale-spellcheck

general/api-client/collection-runner-data-file.mdx#L7

Did you really mean 'Requestly'?
---

You can use **custom data files** (CSV or JSON) when running a collection manually in Requestly.\

Check warning on line 10 in general/api-client/collection-runner-data-file.mdx

View check run for this annotation

Mintlify / Mintlify Validation (requestly) - vale-spellcheck

general/api-client/collection-runner-data-file.mdx#L10

Did you really mean 'Requestly'?
This enables you to iterate through your requests using multiple sets of input values, without modifying your request parameters each time.

<Note>
**Note:** This feature is currently available only on the [Requestly Desktop App](https://requestly.com/downloads/desktop/).

Check warning on line 14 in general/api-client/collection-runner-data-file.mdx

View check run for this annotation

Mintlify / Mintlify Validation (requestly) - vale-spellcheck

general/api-client/collection-runner-data-file.mdx#L14

Did you really mean 'Requestly'?
</Note>

Use this feature to test APIs with dynamic inputs, such as running the same workflow for multiple users, IDs, or configurations.
Expand Down Expand Up @@ -61,7 +61,7 @@

- Each **row (CSV)** or **object (JSON)** represents one **iteration**
- Variables inside your requests (like `{{name}}` or `{{email}}`) are replaced with the corresponding values
- Requestly automatically cycles through each data set until all iterations are complete

Check warning on line 64 in general/api-client/collection-runner-data-file.mdx

View check run for this annotation

Mintlify / Mintlify Validation (requestly) - vale-spellcheck

general/api-client/collection-runner-data-file.mdx#L64

Did you really mean 'Requestly'?

### Supported File Formats

Expand Down Expand Up @@ -112,4 +112,27 @@
London
```

Requestly will automatically replace `{{city}}` with each value during the run.
Requestly will automatically replace `{{city}}` with each value during the run.

Check warning on line 115 in general/api-client/collection-runner-data-file.mdx

View check run for this annotation

Mintlify / Mintlify Validation (requestly) - vale-spellcheck

general/api-client/collection-runner-data-file.mdx#L115

Did you really mean 'Requestly'?

### Accessing Data in Scripts

You can access data file values programmatically in your pre-request and post-response scripts using the `rq.iterationData` object. This allows you to implement conditional logic, validate responses, or perform calculations based on the input data.

**Example:**
```javascript
// Pre-request script
const city = rq.iterationData.get("city");
console.log(`Testing weather API for: ${city}`);

// Post-response script
const expectedCity = rq.iterationData.get("city");
const responseData = rq.response.json();

rq.test("Response contains correct city", function() {
rq.expect(responseData.city).to.equal(expectedCity);
});
```

Learn more about accessing iteration data in scripts:
- [rq.iterationData API Reference](/general/api-client/rq-api-reference/rq-iteration-data)
- [rq.info API Reference](/general/api-client/rq-api-reference/rq-info) - Access iteration metadata
143 changes: 143 additions & 0 deletions general/api-client/rq-api-reference/rq-info.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,143 @@
---
title: rq.info
label: rq.info
slug: rq-info
description: Access execution metadata including request name, iteration index, and event name in Requestly API client scripts.
seoDescription: Access execution metadata including request name, iteration index, and event name in Requestly API client scripts.

Check warning on line 6 in general/api-client/rq-api-reference/rq-info.mdx

View check run for this annotation

Mintlify / Mintlify Validation (requestly) - vale-spellcheck

general/api-client/rq-api-reference/rq-info.mdx#L6

Did you really mean 'Requestly'?
visibility: PUBLIC
---

The `rq.info` object provides metadata about the current script execution context. It contains information about the request being executed, the current iteration (when running collections), and the event type.

## Properties

### `rq.info.requestId`

**Type:** `string`

The unique identifier of the request being executed.

**Example:**
```javascript
console.log("Request ID:", rq.info.requestId);
// Output: Request ID: abc123xyz
```

---

### `rq.info.requestName`

**Type:** `string`

The name of the request being executed.

**Example:**
```javascript
console.log("Executing request:", rq.info.requestName);
// Output: Executing request: Get User Profile
```

---

### `rq.info.eventName`

**Type:** `"prerequest" | "postresponse"`

The type of script event currently executing. Returns `"prerequest"` for pre-request scripts and `"postresponse"` for post-response scripts.

**Example:**
```javascript
if (rq.info.eventName === "prerequest") {
console.log("Running pre-request script");
} else {
console.log("Running post-response script");
}
```

---

### `rq.info.iteration`

**Type:** `number`

The current iteration index when running a collection with the Collection Runner. The index is **0-based**, meaning the first iteration is `0`, the second is `1`, and so on.

For single request executions (not part of a collection run), this value is `0`.

**Example:**
```javascript
console.log("Current iteration:", rq.info.iteration);
// Output: Current iteration: 0 (first iteration)
// Output: Current iteration: 2 (third iteration)
```

---

### `rq.info.iterationCount`

**Type:** `number`

The total number of iterations configured for the collection run. For single request executions, this value is `1`.

**Example:**
```javascript
console.log(`Running iteration ${rq.info.iteration + 1} of ${rq.info.iterationCount}`);
// Output: Running iteration 3 of 10
```

---

## Use Cases

### Track Progress in Collection Runs

```javascript
// Pre-request script
const progress = ((rq.info.iteration + 1) / rq.info.iterationCount * 100).toFixed(1);
console.log(`Progress: ${progress}% (${rq.info.iteration + 1}/${rq.info.iterationCount})`);
```

### Conditional Logic Based on Iteration

```javascript
// Skip authentication on first iteration
if (rq.info.iteration === 0) {
console.log("First iteration - setting up authentication");
rq.environment.set("authToken", "initial-token");
} else {
console.log("Using existing authentication");
}
```

### Different Behavior for First and Last Iterations

```javascript
// Pre-request script
if (rq.info.iteration === 0) {
console.log("First iteration - initializing test data");
rq.collectionVariables.set("testData", []);
}

// Post-response script
if (rq.info.iteration === rq.info.iterationCount - 1) {
console.log("Last iteration - cleaning up");
const allData = rq.collectionVariables.get("testData");
console.log("Collected data from all iterations:", allData);
}
```

### Log Request Context

```javascript
// Post-response script
console.log(`[${rq.info.requestName}] Status: ${rq.response.code} | Iteration: ${rq.info.iteration + 1}/${rq.info.iterationCount}`);
```

---

## Notes

- The `iteration` property is **0-based** (starts from 0, not 1)
- For single request executions, `iteration` is `0` and `iterationCount` is `1`
- The `rq.info` object is read-only and cannot be modified
- All properties are available in both pre-request and post-response scripts
Loading