Using a JSON object from the Request

You can retrieve any part of a JSON Request payload using the following syntax in the response body. (Note that there are similar functions for working with XML should you need to, as well as for working with JSON that is generated from XML)

{{ Request.Body 'JSONpath' '<<JSONpath query expression>>' }}

Example: Using a JSON object from the Request

Request Body

Templating script

Resulting Response Body

{

"person":

{

"name": "John",

"surname": "Doe"

}

}

{{ Request.Body 'JSONpath' '$.person.name' }}

John

{

"people": [

{

"name": "John",

"surname": "Doe",

"age": 30

}

]

}

{{ Request.Body 'JSONpath' '$.people[0].age' }}

30

Last updated