HttpRequestData - Scoped
-
- UpdatedJan 30, 2025
- 8 minutes to read
- Yokohama
- API reference
The HttpRequestData API provides methods to build and manipulate a REST request before applying a signature and sending it to an endpoint.
- HttpRequestData: Build the API request.
- AuthCredential: Create a credential object or update an existing one. Use the credential to sign the request through the RequestAuthAPI class.
- RequestAuthAPI: Sign the request and return an HttpRequestAuthedData object.
- HttpRequestAuthedData: Get information about the signed request.
- GlideHTTPRequest: Send the signed request.
Before using these APIs, you must configure an authentication algorithm to sign the request and associate it with the credential used to authenticate the request.
Use this API in scoped scripts with the sn_auth
namespace identifier. You
can instantiate this class using the constructor, or you can return an HttpRequestData object
from the getHttpRequestData() method in the
RequestAuthAPI class.
HttpRequestData - HttpRequestData()
Instantiates an HttpRequestData object.
Name | Type | Description |
---|---|---|
None |
Example
HttpRequestData - addHeader(String key String value)
Adds a header to the HttpRequestData object.
Name | Type | Description |
---|---|---|
key | String | Name of the HTTP header. |
value | String | Value of the HTTP Header. |
Type | Description |
---|---|
void |
Example
This example creates a REST request payload.
HttpRequestData - addQueryParam(String key, String value)
Adds a query parameter to the HttpRequestData object.
Name | Type | Description |
---|---|---|
key | String | Name of the query parameter. |
value | String | Value of the query parameter. |
Type | Description |
---|---|
void |
Example
HttpRequestData - deleteHeader(String key)
Removes a header from the HttpRequestData object.
Name | Type | Description |
---|---|---|
key | String | Name of the HTTP header to remove. |
Type | Description |
---|---|
void |
Example
HttpRequestData - getConnectionAliasID()
Returns the sys_id of the Connection & Credential alias associated with the Integration Hub REST step.
Name | Type | Description |
---|---|---|
None |
Type | Description |
---|---|
String | Sys_id of the alias record from the Connection & Credential Aliases [sys_alias] table associated with the request. |
Example
HttpRequestData - getConnectionExtendedAttribute(String name)
Returns the value of a connection attribute associated with the Connection & Credential alias associated with Integration Hub REST step.
For more information about connection attributes, see Create connection attributes for Integration Hub.
Name | Type | Description |
---|---|---|
name | String | Name of the connection attribute. |
Type | Description |
---|---|
String | Value of the connection attribute. |
Example
This example returns the value of a connection attribute set on the Connection & Credential alias associated with the REST step.
HttpRequestData - getContent()
Returns the content of the request in the HttpRequestData object.
Name | Type | Description |
---|---|---|
None |
Type | Description |
---|---|
String | Content of the request. |
Example
Output:
HttpRequestData - getDate()
Returns the date when the request was signed.
Name | Type | Description |
---|---|---|
None |
Type | Description |
---|---|
Number | The difference between January 1, 1970 UTC and when the request was
signed. Unit: Milliseconds |
Example
Output:
HttpRequestData - getDirective()
Returns whether the signature is applied to the request in the header or as a query parameter.
By default, the system applies the signature to the header. You can apply the signature as a query parameter using the setDirective() API.
Name | Type | Description |
---|---|---|
None |
Type | Description |
---|---|
String | Whether the signature is applied to the header or as a query parameter.
Values include:
|
Example
Output:
HttpRequestData - getEndpoint()
Returns the endpoint set for the request.
Name | Type | Description |
---|---|---|
None |
Type | Description |
---|---|
String | Endpoint set for the request. |
Example
Output:
HttpRequestData - getExpiry()
Returns the time in seconds before the signature expires starting when the request was signed using the generateAuth() method in the RequestAuthAPI class.
The expiration is commonly set by the third-party service you are sending the request to, which overrides any value set by the setExpiry() method. For example, if the expiration is set to 900 seconds by the third-party service and you use the setExpiry() method to set the expiration to 300 seconds, the getExpiry() method returns 900 seconds.
Name | Type | Description |
---|---|---|
None |
Type | Description |
---|---|
Number | Time before the signature expires. Unit: Seconds |
Example
Output:
HttpRequestData - getHeader(String key)
Returns the value associated with the given HTTP header.
Name | Type | Description |
---|---|---|
key | String | Name of HTTP header. |
Type | Description |
---|---|
String | Value of the given HTTP header. |
Example
Output:
HttpRequestData - getHeaderMap()
Returns an object containing the headers included in the request.
Name | Type | Description |
---|---|---|
None |
Type | Description |
---|---|
Object | Key-value pairs that define all of the headers associated with the request.
Each key-value pair includes these parts:
|
Example
Output:
HttpRequestData - getHost()
Returns the host used in the request.
Name | Type | Description |
---|---|---|
None |
Type | Description |
---|---|
String | Host used in the request. |
Example
Output:
HttpRequestData - getHttpMethod()
Returns the HTTP method used in the request.
Name | Type | Description |
---|---|---|
None |
Type | Description |
---|---|
String | HTTP method used in the request. |
Example
Output:
HttpRequestData - getQueryParam(String key)
Returns the value of the specified query parameter.
Name | Type | Description |
---|---|---|
key | String | Name of the query parameter to get the value of. |
Type | Description |
---|---|
String | Value of the query parameter. |
Example
Output:
HttpRequestData - getQueryParamMap()
Returns an object containing the query parameters included in the request.
Name | Type | Description |
---|---|---|
None |
Type | Description |
---|---|
Object | Key-value pairs that define the query parameters associated with the request.
Each key-value pair includes these parts:
|
Example
Output:
HttpRequestData - getRegion()
Returns the region for the request that will be used in signing.
Name | Type | Description |
---|---|---|
None |
Type | Description |
---|---|
String | Name of the region. |
Example
Output:
HttpRequestData - getService()
Returns the service defined in the request.
Name | Type | Description |
---|---|---|
None |
Type | Description |
---|---|
String | Service defined in the request. |
Example
Output:
HttpRequestData - setContent(String content)
Defines the content to send in the request.
Name | Type | Description |
---|---|---|
content | String | Content to send in the request. |
Type | Description |
---|---|
void |
Example
HttpRequestData - setDate(Number date)
Defines the date of the request used for signing.
Use this method only when testing whether the signature is created correctly based on a time stamp. In production, the signing request uses the time that you generated the signature; manually setting this value may cause the signing request to fail.
Name | Type | Description |
---|---|---|
date | Number | The difference between January 1, 1970 UTC and the date used to sign the
request. Unit: Milliseconds |
Type | Description |
---|---|
void |
Example
HttpRequestData - setDirective(String directive)
Defines whether to apply the signature to the request in a header or as a query parameter.
Name | Type | Description |
---|---|---|
directive | String | Whether to apply the signature to the header or as a query parameter. Values include:
Default: header |
Type | Description |
---|---|
void |
Example
HttpRequestData - setEndpoint(String endpoint)
Defines the endpoint to send the request to.
Name | Type | Description |
---|---|---|
endpoint | String | Endpoint to send the request to. The endpoint can include query parameters, path, and version. |
Type | Description |
---|---|
void |
Example
HttpRequestData - setExpiry(Number expiry)
Sets the amount of time before the signature expires starting when the request is signed using the generateAuth() method in the RequestAuthAPI class.
The expiration is commonly set by the third-party service you are sending the request to, which overrides any value set by the setExpiry() method. For example, if the expiration is set to 900 seconds by the third-party service and you use the setExpiry() method to set the expiration to 300 seconds, the getExpiry() method returns 900 seconds.
Name | Type | Description |
---|---|---|
expiry | Number | Amount of time before the signature expires. Unit: Seconds |
Type | Description |
---|---|
void |
Example
HttpRequestData - setHost(String host)
Defines the host used in the request.
Name | Type | Description |
---|---|---|
host | String | Name of the HTTP request host. |
Type | Description |
---|---|
void |
Example
HttpRequestData - setHttpMethod(String httpMethod)
Sets the HTTP method to use in the request.
Name | Type | Description |
---|---|---|
httpMethod | String | HTTP method to use in the request. |
Type | Description |
---|---|
void |
Example
HttpRequestData - setRegion(String region)
Defines the region to use for the request in signing.
Name | Type | Description |
---|---|---|
region | String | The region to use to sign the request. Available values are determined by the third-party API's requirements. |
Type | Description |
---|---|
void |
Example
HttpRequestData - setService(String service)
Defines the service for the request.
Name | Type | Description |
---|---|---|
service | String | The service for the request. |
Type | Description |
---|---|
void |
Example
On this page
- HttpRequestData - HttpRequestData()
- HttpRequestData - addHeader(String key String value)
- HttpRequestData - addQueryParam(String key, String value)
- HttpRequestData - deleteHeader(String key)
- HttpRequestData - getConnectionAliasID()
- HttpRequestData - getConnectionExtendedAttribute(String name)
- HttpRequestData - getContent()
- HttpRequestData - getDate()
- HttpRequestData - getDirective()
- HttpRequestData - getEndpoint()
- HttpRequestData - getExpiry()
- HttpRequestData - getHeader(String key)
- HttpRequestData - getHeaderMap()
- HttpRequestData - getHost()
- HttpRequestData - getHttpMethod()
- HttpRequestData - getQueryParam(String key)
- HttpRequestData - getQueryParamMap()
- HttpRequestData - getRegion()
- HttpRequestData - getService()
- HttpRequestData - setContent(String content)
- HttpRequestData - setDate(Number date)
- HttpRequestData - setDirective(String directive)
- HttpRequestData - setEndpoint(String endpoint)
- HttpRequestData - setExpiry(Number expiry)
- HttpRequestData - setHost(String host)
- HttpRequestData - setHttpMethod(String httpMethod)
- HttpRequestData - setRegion(String region)
- HttpRequestData - setService(String service)