Request Configuration
This page details how to configure the outgoing HTTP request for an API Node.
Core Settings
- Method: The HTTP method (e.g., GET, POST, PUT, DELETE).
- URL: The full URL for the request, or a relative path if you are using a Server.
- Headers: Key-value pairs for HTTP headers.
- Query Parameters: Key-value pairs that will be automatically encoded and appended to the URL.
- Request Body: The payload for the request. See below for detailed options.
Request Body Composition
The request body can be configured in several formats, including JSON, Form Data, URL-encoded, raw text, or binary file uploads.
Dynamic Values
The URL, headers, and request body all support dynamic values using ReAPI’s template engine.
- Context variables:
{{context.userId}},{{context.authToken}} - Function calls:
${faker.internet.email()},${_.random(1, 100)}
📖 Complete Reference: See Template Engine for comprehensive syntax, built-in functions, and advanced patterns.
JSON Body and the __mixin__ Feature
When using a JSON request body, you can use a special __mixin__ key to merge a context object with other properties in the body. This is extremely useful for GET -> Modify -> PUT/POST workflows.
How it Works:
- Store an object in the context. For example,
context.userDefaults. - Add the
__mixin__key to your request body. Its value should be a template expression pointing to the context object (e.g.,"__mixin__": "{{context.userDefaults}}"). - Add or override properties in the same JSON object.
At runtime, ReAPI will merge the object from the context with the properties you’ve defined. Any properties defined directly in the request body will override properties from the mixed-in object.
Example: Basic Mixin
1. Context Setup:
CONTEXT Node:
Set context.userDefaults = {
"department": "Engineering",
"role": "developer",
"active": true
}2. Request Body with Mixin:
{
"__mixin__": "{{context.userDefaults}}",
"name": "John Doe",
"email": "john@company.com",
"role": "senior_developer"
}3. Resolved Request Body (sent to the server):
{
"department": "Engineering",
"role": "senior_developer",
"active": true,
"name": "John Doe",
"email": "john@company.com"
}Common Pattern: GET → Modify → PUT
The __mixin__ feature is perfect for scenarios where you need to fetch an object, change a few fields, and send the complete object back.
Step 1: GET the current object and store it
- API Node:
GET /users/{{context.userId}} - CONTEXT Node:
Set context.currentUser = response.body
Step 2: PUT the modified object
- API Node:
PUT /users/{{context.userId}} - Request Body:
{ "__mixin__": "{{context.currentUser}}", "role": "senior_developer", "lastModified": "${new Date().toISOString()}" }
This sends the full, original user object but with the role and lastModified fields updated, preventing accidental data loss and ensuring API compliance.