Capture Response Usage
The capture block stores the full HTTP response into a variable so that later requests, conditions, and assertions can reuse it.
Basic Syntax
httpRequest:
capture:
to: VariableName
as: Json|QJson|String|QString|Xml|QXml|Csv|QCsv|Int|Double|Boolean
regex: "optional-regex"
makeGlobal: false
What Gets Captured
When a response is captured, the variable exposes:
BodyStatusCodeStatusReasonHeaders.<HeaderName>
Examples:
${LoginResponse.Body}
${LoginResponse.Body.token}
${LoginResponse.StatusCode}
${LoginResponse.StatusReason}
${LoginResponse.Headers.Content-Type}
${LoginResponse.Headers.Set-Cookie[0]}
Choosing as
Json/QJsonfor JSON response bodiesXml/QXmlfor XML response bodiesCsv/QCsvfor CSV response bodiesString/QStringfor raw text responses
Use the quoted Q* forms when a quoted string is more convenient in expressions.
Example: Capture Users Response
name: TestPlan
rounds:
- name: FeatureRound
numberOfClients: 10
arrivalDelay: 1000
runInParallel: false
iterations:
- name: users
httpRequest:
capture:
to: users
as: Json
makeGlobal: true
url: https://jsonplaceholder.typicode.com/users
method: GET
After this request, you can access values such as:
${users.StatusCode}
${users.Body[0].id}
${users.Body[$length($users.Body)-1].id}
Arithmetic Expressions in Captured Values
Captured values support arithmetic expressions where indexes are used:
- JSON:
${users.Body[0+1].id} - XML:
${catalog.Body/items/item[1+1]/name} - CSV:
${sheet.Body[0+1,1]}
Notes:
- JSON and CSV indexes are zero-based.
- XML follows XPath semantics, so positions are one-based.
- Non-arithmetic selectors remain unchanged.
Scope
- Captured variables are session-scoped by default.
- Set
makeGlobal: truewhen later rounds or other sessions need the same captured value.