Pre-Requests
Pre-Requests
Section titled “Pre-Requests”The @pre directive lets you automatically execute one or more prerequisite requests before the main request runs. This is essential for flows like authentication.
Basic Syntax
Section titled “Basic Syntax”Reference a request by its @id:
###@id abc123@name LoginPOST {{baseUrl}}/auth/loginContent-Type: application/json
{ "email": "{{email}}", "password": "{{password}}"}
@capture env.token = body.access_token
###@name Get Profile@pre abc123GET {{baseUrl}}/profileAuthorization: Bearer {{token}}When you run Get Profile, Rext automatically:
- Executes the Login request first (ID
abc123) - Captures
tokenfrom the login response - Uses
{{token}}in the Get Profile request
Multiple Pre-Requests
Section titled “Multiple Pre-Requests”Chain multiple dependencies in sequential order:
@pre abc123@pre def456@name Full FlowGET {{baseUrl}}/dashboardPre-requests execute in the order they are defined.
Cycle Protection
Section titled “Cycle Protection”How It Works
Section titled “How It Works”graph LR A["@pre abc123"] --> B["Login Request"] B --> C["@capture token"] C --> D["Main Request"] D --> E["Uses {{token}}"]- Rext finds all
@predirectives - Executes each pre-request sequentially
- Any
@capturedirectives in pre-requests set variables - The main request runs with all captured variables available
Next Steps
Section titled “Next Steps”- Learn about assertions for response validation
- Explore retry and timeout settings