Package com.postman.collection
Class Request
java.lang.Object
com.postman.collection.CollectionElement
com.postman.collection.Item
com.postman.collection.Request
Encapsulates a Postman collection request.
Postman SDK analog: Requestinvalid input: '<'/code.
-
Constructor Summary
ConstructorDescriptionRequest
(RequestBody req, String name) Create a request with the specific name and pre-populatedRequestBody
.Create an empety Request with the specific name -
Method Summary
Modifier and TypeMethodDescriptionvoid
addResponse
(Response resp) Add a Response object to theresponse
arrayvoid
addResponse
(String requestKey, Response response) Add a response object to the request contained by this collection specified byrequestKey
Return the object containing the values in therequest
property, or null if this item does not contain a request (e.g., is a folder);Return an ArrayList<Response> containing the values in theresponse
property array, or null if none are defined.void
setRequestBody
(RequestBody request) Set the object containing the values in therequest
propertyvoid
setResponses
(ArrayList<Response> response) Set the ArrayList<Response> containing the values in theresponse
property array.Methods inherited from class com.postman.collection.Item
getDescription, getEvent, getEvents, getKey, getName, getParent, getPreRequestScript, getTestScript, setDescription, setEvents, setName, setParent, setPreRequestScript, setTestScript
Methods inherited from class com.postman.collection.CollectionElement
getCollection, getDefaultCollectionSchema, getDefaultValidationSchema, getUUID, getValidationMessages, isEquivalentTo, setParent, setUUID, toJson, toJson, validate, validate
-
Constructor Details
-
Request
Create a request with the specific name and pre-populatedRequestBody
.- Parameters:
req
- ARequestBody
instance.name
- The name of the request.
-
Request
Create an empety Request with the specific name- Parameters:
name
- The name of the request.
-
-
Method Details
-
getRequestBody
Return the object containing the values in therequest
property, or null if this item does not contain a request (e.g., is a folder);- Returns:
- RequestBody The request, or null if no request is defined.
-
setRequestBody
Set the object containing the values in therequest
property- Parameters:
request
-
-
getResponses
Return an ArrayList<Response> containing the values in theresponse
property array, or null if none are defined.- Returns:
- ArrayList<
Response
> The responses, or null if none are defined.
-
setResponses
Set the ArrayList<Response> containing the values in theresponse
property array. Passing null to this method removes the response array- Parameters:
response
-
-
addResponse
Add a Response object to theresponse
array- Parameters:
resp
- The new response
-
addResponse
public void addResponse(String requestKey, Response response) throws InvalidCollectionActionException Add a response object to the request contained by this collection specified byrequestKey
- Parameters:
requestKey
- Key identifying the request to add the response toresponse
- New response to add to the request- Throws:
InvalidCollectionActionException
- If the specifyed request is not contained by this collection
-