Package com.postman.collection
Class Response
java.lang.Object
com.postman.collection.CollectionElement
com.postman.collection.Response
Class to encapsulate the
response
object property of a Request
.
Postman SDK analog: Response
.
"response": [ { "name": "NORMAL Urlencoded", "originalRequest": { "method": "POST", "url": { "raw": "https://postman-echo.com/post", "host": [ "postman-echo", "com" ], "path": [ "post" ], "protocol": "https" }, "body": { "mode": "urlencoded", "urlencoded": [ { "key": "x-field-2", "value": "value 2", "description": "This is value 2" }, { "key": "x-field-1", "value": "value 1", "description": "This is value 1" } ] } }, "code": 200, "status": "OK", "_postman_previewlanguage": "", "body": "this is the expected response body" } ]The response object includes a RequestBody object describing the original request associated with this response.
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptiongetBody()
Get the value of thebody
property of the response, or null if not set.int
getCode()
Get the value of thecode
property, the HTML status code associated with this response.Return an ArrayList containing the Cookie objects comprising the value of thecookie
array propertyGet the ArrayList containing the key-value paris in theheader
element arraygetKey()
Return the Key for this object.getName()
Get the name of this response.Get the value of theoriginalRequest
for this response as a RequestBody, or null if it has not been set.Get the value of the_postman_previewlanguage
propertyGet the value of thestatus
property for this response, the string associated with thecode>
property, eg.void
Set the value of thebody
property of the responsevoid
setCode
(int code) Set the value of thecode
property, the HTML status code associated with this response.void
setCookies
(ArrayList<Cookie> cookie) Set the value of thecookie
array property with a pre-populated ArrayListvoid
setHeader
(PropertyList<Property> headers) Set the value of theheader
element array with a pre-populated ArrayList of Property key-value pairsvoid
Set the name of this responsevoid
setOriginalRequest
(RequestBody originalRequest) Set the value of theoriginalRequest
propertyvoid
SetPostmanPreviewlanguage
(String previewLanguage) Set the value of the_postman_previewlanguage
propertyvoid
Set the value of thestatus
property for this response, the string associated with thecode>
property, eg.Methods inherited from class com.postman.collection.CollectionElement
getCollection, getDefaultCollectionSchema, getDefaultValidationSchema, getParent, getUUID, getValidationMessages, isEquivalentTo, setParent, setUUID, toJson, toJson, validate, validate
-
Constructor Details
-
Response
-
Response
-
-
Method Details
-
setHeader
Set the value of theheader
element array with a pre-populated ArrayList of Property key-value pairs- Parameters:
headers
-
-
getHeader
Get the ArrayList containing the key-value paris in theheader
element array- Returns:
- ArrayList<
Property
>
-
getName
Get the name of this response.- Returns:
- String The name
-
setName
Set the name of this response- Parameters:
name
- The name
-
getOriginalRequest
Get the value of theoriginalRequest
for this response as a RequestBody, or null if it has not been set.- Returns:
- RequestBody
-
setOriginalRequest
Set the value of theoriginalRequest
property- Parameters:
originalRequest
-
-
getCode
public int getCode()Get the value of thecode
property, the HTML status code associated with this response.- Returns:
- int
-
setCode
public void setCode(int code) Set the value of thecode
property, the HTML status code associated with this response.- Parameters:
code
-
-
getStatus
Get the value of thestatus
property for this response, the string associated with thecode>
property, eg. "OK"- Returns:
- String The status as a string, eg. "OK"
-
setStatus
Set the value of thestatus
property for this response, the string associated with thecode>
property, eg. "OK"- Parameters:
status
- The status. Not validated against existing http response codes
-
getPostmanPreviewlanguage
Get the value of the_postman_previewlanguage
property- Returns:
- String The language
-
SetPostmanPreviewlanguage
Set the value of the_postman_previewlanguage
property- Parameters:
previewLanguage
- The language
-
getCookies
Return an ArrayList containing the Cookie objects comprising the value of thecookie
array property- Returns:
- ArrayList<
Cookie
> The cookies
-
setCookies
Set the value of thecookie
array property with a pre-populated ArrayList- Parameters:
cookie
-
-
getBody
Get the value of thebody
property of the response, or null if not set.- Returns:
- String The body
-
setBody
Set the value of thebody
property of the response- Parameters:
body
- The body.
-
getKey
Return the Key for this object. Not currently implemented- Specified by:
getKey
in classCollectionElement
- Returns:
- String The key
-