Package com.postman.collection
Class RequestBody
java.lang.Object
com.postman.collection.CollectionElement
com.postman.collection.RequestBody
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=1&bar=",
"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 Summary
ConstructorDescriptionRequestBody
(enumHTTPRequestMethod method, Url url) Construct a RequestBody with the specified HTTP method, and Url.RequestBody
(enumHTTPRequestMethod method, String URL) Construct a RequestBody object from a raw URL.RequestBody
(enumHTTPRequestMethod method, String host, String path) Construct a RequestBody with the specified HTTP method, host and path. -
Method Summary
Modifier and TypeMethodDescriptiongetAuth()
Get theRequestAuth
object containing the values of theauth
array, or null if it has not been set.getBody()
Return the PostmanBody object containing the values in thebody
property object, or null if it has not been set.Get the value of thedescription
property, generally the documentation for the requestReturn an ArrayList of Property objects containing the key-value pair values for theheader
property arraygetKey()
Returns the value of thename
propertyReturn the enumerated value of themethod
propertygetUrl()
Return the Url containing the values of theurl
property arraygetUrl
(boolean resolveVariables) void
setAuth
(RequestAuth auth) Set the values in theauth
array with a pre-populatedRequestAuth
object.void
setBody
(BodyElement body) Set the value of thebody
property objectsetBody
(enumRequestBodyMode bodyMode) Populate thebody
array with an emptybody
property object with the specifiedmode
value.setBody
(enumRequestBodyMode bodyMode, String rawContent) Populate thebody
array with the specified body content.void
setDescription
(String description) Set the value of thedescription
property, generally the documentation for the requestvoid
setHeader
(PropertyList<Property> header) Set the key-value pair values for theheader
property arrayvoid
setMethod
(enumHTTPRequestMethod method) Set the value of themethod
propertyvoid
Set the values of theurl
propertyMethods inherited from class com.postman.collection.CollectionElement
getCollection, getDefaultCollectionSchema, getDefaultValidationSchema, getParent, getUUID, getValidationMessages, isEquivalentTo, setParent, setUUID, toJson, toJson, validate, validate
-
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 methodhost
- String containing the host portion of the URL.path
- String containing the path portion of the URL.- Throws:
DuplicateVariableKeyException
-
RequestBody
Construct a RequestBody with the specified HTTP method, and Url.- Parameters:
method
- Enumerated value for the HTTP methodurl
- Pre-constructed Url object
-
RequestBody
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 methodURL
- The raw URL- Throws:
DuplicateVariableKeyException
-
-
Method Details
-
getKey
Returns the value of thename
property- Specified by:
getKey
in classCollectionElement
- Returns:
- String
-
setAuth
Set the values in theauth
array with a pre-populatedRequestAuth
object.- Parameters:
auth
- The auth
-
getAuth
Get theRequestAuth
object containing the values of theauth
array, or null if it has not been set.- Returns:
- RequestAuth The auth object containing the values.
-
getMethod
Return the enumerated value of themethod
property- Returns:
- enumHTTPRequestMethod
-
setMethod
Set the value of themethod
property- Parameters:
method
-
-
getUrl
Return the Url containing the values of theurl
property array- Returns:
- Url
-
getUrl
- Parameters:
resolveVariables
-- Returns:
- String
- Throws:
VariableResolutionException
-
setUrl
Set the values of theurl
property- Parameters:
url
- Url object containing the values
-
getHeader
Return an ArrayList of Property objects containing the key-value pair values for theheader
property array- Returns:
- ArrayList<
Property
> The headers, or null if none are present
-
setHeader
Set the key-value pair values for theheader
property array- Parameters:
header
- Header values
-
getDescription
Get the value of thedescription
property, generally the documentation for the request- Returns:
- String The description
-
setDescription
Set the value of thedescription
property, generally the documentation for the request- Parameters:
description
- The description
-
setBody
Populate thebody
array with an emptybody
property object with the specifiedmode
value.- Parameters:
bodyMode
- The body mode, eg. RAW- Returns:
- PostmanBody The new body
-
setBody
Populate thebody
array with the specified body content. Thelanguage
property of the request will best set to "text"- Parameters:
bodyMode
- Enumerated value for themode
propertyrawContent
- The raw content for the body- Returns:
- PostmanBody The new body
-
getBody
Return the PostmanBody object containing the values in thebody
property object, or null if it has not been set.- Returns:
- PostmanBody The body, or null.
-
setBody
Set the value of thebody
property object- Parameters:
body
- The new body values
-