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
ConstructorsConstructorDescriptionRequestBody(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 theRequestAuthobject containing the values of theautharray, or null if it has not been set.getBody()Return the PostmanBody object containing the values in thebodyproperty object, or null if it has not been set.Get the value of thedescriptionproperty, generally the documentation for the requestReturn an ArrayList of Property objects containing the key-value pair values for theheaderproperty arraygetKey()Returns the value of thenamepropertyReturn the enumerated value of themethodpropertygetUrl()Return the Url containing the values of theurlproperty arraygetUrl(boolean resolveVariables) voidsetAuth(RequestAuth auth) Set the values in theautharray with a pre-populatedRequestAuthobject.voidsetBody(BodyElement body) Set the value of thebodyproperty objectsetBody(enumRequestBodyMode bodyMode) Populate thebodyarray with an emptybodyproperty object with the specifiedmodevalue.setBody(enumRequestBodyMode bodyMode, String rawContent) Populate thebodyarray with the specified body content.voidsetDescription(String description) Set the value of thedescriptionproperty, generally the documentation for the requestvoidsetHeader(PropertyList<Property> header) Set the key-value pair values for theheaderproperty arrayvoidsetMethod(enumHTTPRequestMethod method) Set the value of themethodpropertyvoidSet the values of theurlpropertyMethods 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 thenameproperty- Specified by:
getKeyin classCollectionElement- Returns:
- String
-
setAuth
Set the values in theautharray with a pre-populatedRequestAuthobject.- Parameters:
auth- The auth
-
getAuth
Get theRequestAuthobject containing the values of theautharray, or null if it has not been set.- Returns:
- RequestAuth The auth object containing the values.
-
getMethod
Return the enumerated value of themethodproperty- Returns:
- enumHTTPRequestMethod
-
setMethod
Set the value of themethodproperty- Parameters:
method-
-
getUrl
Return the Url containing the values of theurlproperty array- Returns:
- Url
-
getUrl
- Parameters:
resolveVariables-- Returns:
- String
- Throws:
VariableResolutionException
-
setUrl
Set the values of theurlproperty- Parameters:
url- Url object containing the values
-
getHeader
Return an ArrayList of Property objects containing the key-value pair values for theheaderproperty array- Returns:
- ArrayList<
Property> The headers, or null if none are present
-
setHeader
Set the key-value pair values for theheaderproperty array- Parameters:
header- Header values
-
getDescription
Get the value of thedescriptionproperty, generally the documentation for the request- Returns:
- String The description
-
setDescription
Set the value of thedescriptionproperty, generally the documentation for the request- Parameters:
description- The description
-
setBody
Populate thebodyarray with an emptybodyproperty object with the specifiedmodevalue.- Parameters:
bodyMode- The body mode, eg. RAW- Returns:
- PostmanBody The new body
-
setBody
Populate thebodyarray with the specified body content. Thelanguageproperty of the request will best set to "text"- Parameters:
bodyMode- Enumerated value for themodepropertyrawContent- The raw content for the body- Returns:
- PostmanBody The new body
-
getBody
Return the PostmanBody object containing the values in thebodyproperty object, or null if it has not been set.- Returns:
- PostmanBody The body, or null.
-
setBody
Set the value of thebodyproperty object- Parameters:
body- The new body values
-