Class Response


public class Response extends CollectionElement
Class to encapsulate the response object property of a Request.

Postman SDK analog: Response.

A RequestBody includes an optional array of expected responses:
  "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 Details

  • Method Details

    • setHeader

      public void setHeader(PropertyList<Property> headers)
      Set the value of the header element array with a pre-populated ArrayList of Property key-value pairs
      Parameters:
      headers -
    • getHeader

      public PropertyList<Property> getHeader()
      Get the ArrayList containing the key-value paris in the header element array
      Returns:
      ArrayList<Property>
    • getName

      public String getName()
      Get the name of this response.
      Returns:
      String The name
    • setName

      public void setName(String name)
      Set the name of this response
      Parameters:
      name - The name
    • getOriginalRequest

      public RequestBody getOriginalRequest()
      Get the value of the originalRequest for this response as a RequestBody, or null if it has not been set.
      Returns:
      RequestBody
    • setOriginalRequest

      public void setOriginalRequest(RequestBody originalRequest)
      Set the value of the originalRequest property
      Parameters:
      originalRequest -
    • getCode

      public int getCode()
      Get the value of the code property, the HTML status code associated with this response.
      Returns:
      int
    • setCode

      public void setCode(int code)
      Set the value of the code property, the HTML status code associated with this response.
      Parameters:
      code -
    • getStatus

      public String getStatus()
      Get the value of the status property for this response, the string associated with the code> property, eg. "OK"
      Returns:
      String The status as a string, eg. "OK"
    • setStatus

      public void setStatus(String status)
      Set the value of the status property for this response, the string associated with the code> property, eg. "OK"
      Parameters:
      status - The status. Not validated against existing http response codes
    • getPostmanPreviewlanguage

      public String getPostmanPreviewlanguage()
      Get the value of the _postman_previewlanguage property
      Returns:
      String The language
    • SetPostmanPreviewlanguage

      public void SetPostmanPreviewlanguage(String previewLanguage)
      Set the value of the _postman_previewlanguage property
      Parameters:
      previewLanguage - The language
    • getCookies

      public ArrayList<Cookie> getCookies()
      Return an ArrayList containing the Cookie objects comprising the value of the cookie array property
      Returns:
      ArrayList<Cookie> The cookies
    • setCookies

      public void setCookies(ArrayList<Cookie> cookie)
      Set the value of the cookie array property with a pre-populated ArrayList
      Parameters:
      cookie -
    • getBody

      public String getBody()
      Get the value of the body property of the response, or null if not set.
      Returns:
      String The body
    • setBody

      public void setBody(String body)
      Set the value of the body property of the response
      Parameters:
      body - The body.
    • getKey

      public String getKey()
      Return the Key for this object. Not currently implemented
      Specified by:
      getKey in class CollectionElement
      Returns:
      String The key