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
Constructors -
Method Summary
Modifier and TypeMethodDescriptiongetBody()Get the value of thebodyproperty of the response, or null if not set.intgetCode()Get the value of thecodeproperty, the HTML status code associated with this response.Return an ArrayList containing the Cookie objects comprising the value of thecookiearray propertyGet the ArrayList containing the key-value paris in theheaderelement arraygetKey()Return the Key for this object.getName()Get the name of this response.Get the value of theoriginalRequestfor this response as a RequestBody, or null if it has not been set.Get the value of the_postman_previewlanguagepropertyGet the value of thestatusproperty for this response, the string associated with thecode>property, eg.voidSet the value of thebodyproperty of the responsevoidsetCode(int code) Set the value of thecodeproperty, the HTML status code associated with this response.voidsetCookies(ArrayList<Cookie> cookie) Set the value of thecookiearray property with a pre-populated ArrayListvoidsetHeader(PropertyList<Property> headers) Set the value of theheaderelement array with a pre-populated ArrayList of Property key-value pairsvoidSet the name of this responsevoidsetOriginalRequest(RequestBody originalRequest) Set the value of theoriginalRequestpropertyvoidSetPostmanPreviewlanguage(String previewLanguage) Set the value of the_postman_previewlanguagepropertyvoidSet the value of thestatusproperty 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 theheaderelement array with a pre-populated ArrayList of Property key-value pairs- Parameters:
headers-
-
getHeader
Get the ArrayList containing the key-value paris in theheaderelement 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 theoriginalRequestfor this response as a RequestBody, or null if it has not been set.- Returns:
- RequestBody
-
setOriginalRequest
Set the value of theoriginalRequestproperty- Parameters:
originalRequest-
-
getCode
public int getCode()Get the value of thecodeproperty, the HTML status code associated with this response.- Returns:
- int
-
setCode
public void setCode(int code) Set the value of thecodeproperty, the HTML status code associated with this response.- Parameters:
code-
-
getStatus
Get the value of thestatusproperty 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 thestatusproperty 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_previewlanguageproperty- Returns:
- String The language
-
SetPostmanPreviewlanguage
Set the value of the_postman_previewlanguageproperty- Parameters:
previewLanguage- The language
-
getCookies
Return an ArrayList containing the Cookie objects comprising the value of thecookiearray property- Returns:
- ArrayList<
Cookie> The cookies
-
setCookies
Set the value of thecookiearray property with a pre-populated ArrayList- Parameters:
cookie-
-
getBody
Get the value of thebodyproperty of the response, or null if not set.- Returns:
- String The body
-
setBody
Set the value of thebodyproperty of the response- Parameters:
body- The body.
-
getKey
Return the Key for this object. Not currently implemented- Specified by:
getKeyin classCollectionElement- Returns:
- String The key
-