Class RequestBody


public class RequestBody extends CollectionElement
Encapsulates the request object property of a Request

Postman SDK analog: RequestBodyinvalid input: '<'/code.


 {
    "name": "URL 7",
    "request": {
        "method": "GET",
        "header": [],
        "url": {
            "raw": "{{baseUrl}}foo.com/bar/:path1/bat.json?foo&#61;1&bar&#61;",
            "host": [
                "{{baseUrl}}foo",
                "com"
            ],
            "path": [
                "bar",
                ":path1",
                "bat.json"
            ],
            "query": [
                {
                    "key": "foo",
                    "value": "1"
                },
                {
                    "key": "bar",
                    "value": ""
                }
            ],
            "variable": [
                {
                    "key": "path1",
                    "value": "path-value"
                }
            ]
        }
    },
    "response": []
}
*
  • Constructor Details

    • RequestBody

      public RequestBody(enumHTTPRequestMethod method, String host, String path) throws DuplicateVariableKeyException
      Construct a RequestBody with the specified HTTP method, host and path. All URL components are constructed from the host and path strings.
      Parameters:
      method - Enumerated value for the HTTP method
      host - String containing the host portion of the URL.
      path - String containing the path portion of the URL.
      Throws:
      DuplicateVariableKeyException
    • RequestBody

      public RequestBody(enumHTTPRequestMethod method, Url url)
      Construct a RequestBody with the specified HTTP method, and Url.
      Parameters:
      method - Enumerated value for the HTTP method
      url - Pre-constructed Url object
    • RequestBody

      public RequestBody(enumHTTPRequestMethod method, String URL) throws DuplicateVariableKeyException
      Construct a RequestBody object from a raw URL. All path, host, URL, auth and other property array elements are parsed out and populated
      Parameters:
      method - Enumerated value for the HTTP method
      URL - The raw URL
      Throws:
      DuplicateVariableKeyException
  • Method Details

    • getKey

      public String getKey()
      Returns the value of the name property
      Specified by:
      getKey in class CollectionElement
      Returns:
      String
    • setAuth

      public void setAuth(RequestAuth auth)
      Set the values in the auth array with a pre-populated RequestAuth object.
      Parameters:
      auth - The auth
    • getAuth

      public RequestAuth getAuth()
      Get the RequestAuth object containing the values of the auth array, or null if it has not been set.
      Returns:
      RequestAuth The auth object containing the values.
    • getMethod

      public enumHTTPRequestMethod getMethod()
      Return the enumerated value of the method property
      Returns:
      enumHTTPRequestMethod
    • setMethod

      public void setMethod(enumHTTPRequestMethod method)
      Set the value of the method property
      Parameters:
      method -
    • getUrl

      public Url getUrl()
      Return the Url containing the values of the url property array
      Returns:
      Url
    • getUrl

      public String getUrl(boolean resolveVariables) throws VariableResolutionException
      Parameters:
      resolveVariables -
      Returns:
      String
      Throws:
      VariableResolutionException
    • setUrl

      public void setUrl(Url url)
      Set the values of the url property
      Parameters:
      url - Url object containing the values
    • getHeader

      public PropertyList<Property> getHeader()
      Return an ArrayList of Property objects containing the key-value pair values for the header property array
      Returns:
      ArrayList<Property> The headers, or null if none are present
    • setHeader

      public void setHeader(PropertyList<Property> header)
      Set the key-value pair values for the header property array
      Parameters:
      header - Header values
    • getDescription

      public String getDescription()
      Get the value of the description property, generally the documentation for the request
      Returns:
      String The description
    • setDescription

      public void setDescription(String description)
      Set the value of the description property, generally the documentation for the request
      Parameters:
      description - The description
    • setBody

      public BodyElement setBody(enumRequestBodyMode bodyMode)
      Populate the body array with an empty body property object with the specified mode value.
      Parameters:
      bodyMode - The body mode, eg. RAW
      Returns:
      PostmanBody The new body
    • setBody

      public BodyElement setBody(enumRequestBodyMode bodyMode, String rawContent)
      Populate the body array with the specified body content. The language property of the request will best set to "text"
      Parameters:
      bodyMode - Enumerated value for the mode property
      rawContent - The raw content for the body
      Returns:
      PostmanBody The new body
    • getBody

      public BodyElement getBody()
      Return the PostmanBody object containing the values in the body property object, or null if it has not been set.
      Returns:
      PostmanBody The body, or null.
    • setBody

      public void setBody(BodyElement body)
      Set the value of the body property object
      Parameters:
      body - The new body values