res object is available inside the vars, assertions, scripting, and testing contexts. Use it to extract values from the response body, headers, and status.
The res object is only available in the context of a request.
You can also query nested response data using response queries.
Properties
| Property | Description |
|---|---|
res.status | HTTP status code (e.g., 200, 404) |
res.statusText | HTTP status text (e.g., "OK", "Not Found") |
res.headers | Key-value pairs of HTTP response headers |
res.body | The parsed response body (string, object, etc.) |
res.responseTime | Time in milliseconds the request took to complete |
res.url | The full URL of the request |
Methods
| Method | Description |
|---|---|
res.getStatus() | Returns the HTTP status code |
res.getStatusText() | Returns the HTTP status text |
res.getHeader(name) | Returns the value of a specific response header |
res.getHeaders() | Returns all response headers |
res.getBody() | Returns the response body |
res.getResponseTime() | Returns the response time in milliseconds |
res.getUrl() | Returns the request URL |
res.setBody(data) | Replaces the response body with new data |
res.getSize() | Returns an object with header, body, and total byte sizes |