new Request(options)
A Postman HTTP request object.
Parameters:
Name | Type | Description |
---|---|---|
options |
Request.definition |
- Source:
Extends
Members
auth :RequestAuth
Type:
- Source:
body :RequestBody|undefined
Type:
- RequestBody | undefined
- Source:
certificate :Certificate|undefined
Type:
- Certificate | undefined
- Source:
disabled :Boolean
This (optional) flag denotes whether this property is disabled or not. Usually, this is helpful when a property is part of a PropertyList. For example, in a PropertyList of Headers, the ones that are disabled can be filtered out and not processed.
Type:
- Boolean
- Inherited From:
- Source:
headers :HeaderList
Type:
- Source:
id :String
The id
of the property is a unique string that identifies this property and can be used to refer to
this property from relevant other places. It is a good practice to define the id or let the system
auto generate a UUID if one is not defined for properties that require an id
.
Type:
- String
- Inherited From:
- Source:
method :String
Type:
- String
- Source:
name :String
A property can have a distinctive and human-readable name. This is to be used to display the name of the
property within Postman, Newman or other runtimes that consume collection. In certain cases, the absence
of name might cause the runtime to use the id
as a fallback.
Type:
- String
- Inherited From:
- Source:
proxy :ProxyConfig
Type:
- Source:
url :Url
Type:
- Source:
Methods
(static) isRequest(obj) → {Boolean}
Check whether an object is an instance of ItemGroup.
Parameters:
Name | Type | Description |
---|---|---|
obj |
* |
- Source:
Returns:
- Type
- Boolean
addHeader(header)
Adds a header to the PropertyList of headers.
Parameters:
Name | Type | Description |
---|---|---|
header |
Header | Object | Can be a {Header} object, or a raw header object. |
- Source:
addQueryParams(params)
Add query parameters to the request.
Parameters:
Name | Type | Description |
---|---|---|
params |
Array.<QueryParam> | String |
- Source:
authorizeUsing(type, optionsopt)
Sets authentication method for the request
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
type |
String | RequestAuth.definition | ||
options |
VariableList |
<optional> |
- Source:
clone() → {Request}
Creates a clone of this request
- Source:
Returns:
- Type
- Request
describe(content, typeopt)
This function allows to describe the property for the purpose of detailed identification or documentation
generation. This function sets or updates the description
child-property of this property.
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
content |
String | The content of the description can be provided here as a string. Note that it is expected
that if the content is formatted in any other way than simple text, it should be specified in the subsequent
|
||
type |
String |
<optional> |
"text/plain" | The type of the content. |
- Inherited From:
- Source:
Example
var Collection = require('postman-collection').Collection,
mycollection;
// create a blank collection
myCollection = new Collection();
myCollection.describe('Hey! This is a cool collection.');
console.log(myCollection.description.toString()); // read the description
findInParents(property, customizeropt) → {*|undefined}
Tries to find the given property locally, and then proceeds to lookup in each parent,
going up the chain as necessary. Lookup will continue until customizer
returns a truthy value. If used
without a customizer, the lookup will stop at the first parent that contains the property.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
property |
String | ||
customizer |
function |
<optional> |
- Inherited From:
- Source:
Returns:
- Type
- * | undefined
forEachHeader(callback)
Calls the given callback on each Header object contained within the request.
Parameters:
Name | Type | Description |
---|---|---|
callback |
function |
- Source:
forEachParent(options, iterator)
Invokes the given iterator for every parent in the parent chain of the given element.
Parameters:
Name | Type | Description | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
options |
Object | A set of options for the parent chain traversal. Properties
|
||||||||||
iterator |
function | The function to call for every parent in the ancestry chain. |
- Inherited From:
- Source:
- To Do:
-
- Cache the results
getHeaders(optionsopt) → {Object}
Returns an object where the key is a header name and value is the header value.
Parameters:
Name | Type | Attributes | Description | |||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
options |
Object |
<optional> |
Properties
|
- Source:
Returns:
- Type
- Object
meta() → {*}
Returns the meta keys associated with the property
- Inherited From:
- Source:
Returns:
- Type
- *
parent() → {*|undefined}
Returns the parent of item
- Inherited From:
- Source:
Returns:
- Type
- * | undefined
removeHeader(toRemove, options)
Removes a header from the request.
Parameters:
Name | Type | Description | ||||||
---|---|---|---|---|---|---|---|---|
toRemove |
String | Header | A header object to remove, or a string containing the header key. |
||||||
options |
Object | Properties
|
- Source:
removeQueryParams(params)
Removes parameters passed in params.
Parameters:
Name | Type | Description |
---|---|---|
params |
String | Array |
- Source:
size() → {Object}
Get the request size by computing the headers and body or using the actual content length header once the request is sent.
- Source:
Returns:
- Type
- Object
toJSON() → {Object}
Converts the Request to a plain JavaScript object, which is also how the request is represented in a collection file.
- Overrides:
- Source:
Returns:
- Type
- Object
update(options)
Updates the different properties of the request.
Parameters:
Name | Type | Description |
---|---|---|
options |
Request.definition |
- Source:
upsertHeader(header)
Updates or inserts the given header.
Parameters:
Name | Type | Description |
---|---|---|
header |
Object |
- Source:
Type Definitions
definition
Properties:
Name | Type | Description |
---|---|---|
url |
String | Url | The URL of the request. This can be a Url.definition or a string. |
method |
String | The request method, e.g: "GET" or "POST". |
header |
Array.<Header.definition> | The headers that should be sent as a part of this request. |
body |
RequestBody.definition | The request body definition. |
auth |
RequestAuth.definition | The authentication/signing information for this request. |
proxy |
ProxyConfig.definition | The proxy information for this request. |
certificate |
Certificate.definition | The certificate information for this request. |
- Source: