Defining Variables
Variables allow you to extract data from request, subtest, and Ghost Inspector steps for use in subsequent steps in the test. Similar to Assertions, each variable is defined by a name, source, and property.
Defining VariablesSample POST Body (JSON) to set {{myUserId}} to the value of JSON element 'user_id'
"variables": [
{
"source": "response_json",
"property": "user_id",
"name": "myUserId"
}
]
Variable Sources List
Sources
-
response_statusCreate a variable from the value of the HTTP status code from the Response
-
response_headersCreate a variable from the value of a Response Header. You must include a property with the name of the header to extract the value from
-
response_jsonParse the response body as JSON. You must include a property with the JSON path to extract
-
response_xmlParse the response body as XML. You must include a property with the XPath to extract
-
response_textParse the response body as plain text. This source does not specify a
property -
response_timeCreate a variable from the execution time of the response in milliseconds
-
response_sizeCreate a variable from the size of the Response body in bytes