Skip to content
Release: Australia · Updated: 2026-03-12 · Official documentation · View source

HttpRequestData- Scoped

The HttpRequestData API provides methods to build and manipulate a REST request before applying a signature and sending it to an endpoint.

Generate outbound signing requests using these APIs in the following order:

  1. HttpRequestData: Build the API request.
  2. AuthCredential: Create a credential object or update an existing one. Use the credential to sign the request through the RequestAuthAPI class.
  3. RequestAuthAPI: Sign the request and return an HttpRequestAuthedData object.
  4. HttpRequestAuthedData: Get information about the signed request.
  5. 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.

Parent Topic:Server API reference

HttpRequestData - HttpRequestData()

Instantiates an HttpRequestData object.

NameTypeDescription
None  
var httpRequestData = new sn_auth.HttpRequestData();

HttpRequestData - addHeader(String key String value)

Adds a header to the HttpRequestData object.

NameTypeDescription
keyStringName of the HTTP header.
valueStringValue of the HTTP Header.
TypeDescription
void 

This example creates a REST request payload.

var endpoint= "https://s3.amazonaws.com";
var httpRequestData = new sn_auth.HttpRequestData();
httpRequestData.setEndpoint(endpoint);
httpRequestData.setService('s3');
httpRequestData.setRegion('us-east-1');
httpRequestData.setHttpMethod("PUT");
var content = "Action=SendMessage&MessageBody=This is a test message";
httpRequestData.setContent(content);
httpRequestData.addHeader('x-amz-acl', 'public-read' );

HttpRequestData - addQueryParam(String key, String value)

Adds a query parameter to the HttpRequestData object.

NameTypeDescription
keyStringName of the query parameter.
valueStringValue of the query parameter.
TypeDescription
void 
var endpoint= "https://third-party-endpoint";
var httpRequestData = new sn_auth.HttpRequestData();
httpRequestData.setEndpoint(endpoint);
httpRequestData.setService('s3');
httpRequestData.setRegion('us-east-1');
httpRequestData.setHttpMethod('put');
var content = "Action=SendMessage&MessageBody=This is a test message";
httpRequestData.setContent(content);
httpRequestData.addQueryParam('api_version', 'v2 );
​

HttpRequestData - deleteHeader(String key)

Removes a header from the HttpRequestData object.

NameTypeDescription
keyStringName of the HTTP header to remove.
TypeDescription
void 
var endpoint= "https://s3.amazonaws.com";
var httpRequestData = new sn_auth.HttpRequestData();
httpRequestData.setEndpoint(endpoint);
httpRequestData.setService('s3');
httpRequestData.setRegion('us-east-1');
httpRequestData.setHttpMethod('put');
var content = "Action=SendMessage&MessageBody=This is a test message";
httpRequestData.setContent(content);
httpRequestData.deleteHeader('x-amz-acl');

HttpRequestData - getConnectionAliasID()

Returns the sys_id of the Connection & Credential alias associated with the Integration Hub REST step.

You can pass the sys_id to the ConnectionInfoProvider API to retrieve information about the connection.

Note: You can only use this method in an Integration Hub REST step. For more information, see REST step.

NameTypeDescription
None  
TypeDescription
StringSys_id of the alias record from the Connection & Credential Aliases [sys_alias] table associated with the request.
var httpRequestData = new sn_auth.HttpRequestData();
var id = httpRequestData.getConnectionAliasID();

var credential = new sn_cc.ConnectionInfoProvider().
var connectionInfo = credential.getConnectionInfo(id);

HttpRequestData - getConnectionExtendedAttribute(String name)

Returns the value of a connection attribute associated with the Connection & Credential alias associated with Integration Hub REST step.

Note: You can only use this method in an Integration Hub REST step. For more information, see REST step.

For more information about connection attributes, see Create connection attributes for Integration Hub.

NameTypeDescription
nameStringName of the connection attribute.
TypeDescription
StringValue of the connection attribute.

This example returns the value of a connection attribute set on the Connection & Credential alias associated with the REST step.

var httpRequestData = new sn_auth.HttpRequestData();​
gs.info("API Version is: " + httpRequestData.getConnectionExtendedAttribute('api_version'));

HttpRequestData - getContent()

Returns the content of the request in the HttpRequestData object.

NameTypeDescription
None  
TypeDescription
StringContent of the request.
var endpoint= "https://s3.amazonaws.com";
var httpRequestData = new sn_auth.HttpRequestData();
httpRequestData.setEndpoint(endpoint);
httpRequestData.setService('s3');
httpRequestData.setRegion('us-east-1');
httpRequestData.setHttpMethod('put');
var content = "Action=SendMessage&MessageBody=This is a test message";
httpRequestData.setContent(content);
httpRequestData.addHeader('x-amz-acl' , 'public-read' );
var ct = httpRequestData.getContent();

Output:

Action=SendMessage&MessageBody=This is a test message

HttpRequestData - getDate()

Returns the date when the request was signed.

NameTypeDescription
None  
TypeDescription
NumberThe difference between January 1, 1970 UTC and when the request was signed.Unit: Milliseconds
var endpoint= "https://s3.amazonaws.com";​
var httpRequestData = new sn_auth.HttpRequestData();​
httpRequestData.setEndpoint(endpoint);​
httpRequestData.addQueryParam("list-type", "2");​
httpRequestData.setService('s3');​
httpRequestData.setHttpMethod('get');​

gs.info( "Date: " + httpRequestData.getDate());

Output:

Date: 1349333576093

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.

NameTypeDescription
None  
TypeDescription
StringWhether the signature is applied to the header or as a query parameter. Values include: - HEADER: The signature is applied to the request header. - QUERY: The signature is applied as a query parameter.
var endpoint= "https://s3.amazonaws.com";​
var httpRequestData = new sn_auth.HttpRequestData();​
httpRequestData.setEndpoint(endpoint);​
httpRequestData.addQueryParam("list-type", "2");​
httpRequestData.setService('s3');​
httpRequestData.setHttpMethod('get');​

gs.info( "Signature applied to: " + httpRequestData.getDirective() );

Output:

Signature applied to: HEADER

HttpRequestData - getEndpoint()

Returns the endpoint set for the request.

NameTypeDescription
None  
TypeDescription
StringEndpoint set for the request.
var endpoint= "https://s3.amazonaws.com";​
var httpRequestData = new sn_auth.HttpRequestData();​
httpRequestData.setEndpoint(endpoint);​
httpRequestData.addQueryParam("list-type", "2");​
httpRequestData.setService('s3');​
httpRequestData.setHttpMethod('get');​
httpRequestData.setDirective("query");​
​
gs.info( "Endpoint is: " + httpRequestData.getEndpoint() );

Output:

Endpoint is: https://s3.amazonaws.com

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.

NameTypeDescription
None  
TypeDescription
NumberTime before the signature expires.Unit: Seconds
var endpoint= "https://s3.amazonaws.com";​
var httpRequestData = new sn_auth.HttpRequestData();​
httpRequestData.setEndpoint(endpoint);​
httpRequestData.addQueryParam("list-type", "2");​
httpRequestData.setService('s3');​
httpRequestData.setHttpMethod('get');​
httpRequestData.setDirective("query");​
httpRequestData.setExpiry(300);

gs.info("Signature expires in: " + httpRequestData.getExpiry());

Output:

Signature expires in: 300

HttpRequestData - getHeader(String key)

Returns the value associated with the given HTTP header.

NameTypeDescription
keyStringName of HTTP header.
TypeDescription
StringValue of the given HTTP header.
var endpoint= "https://third-party-endpoint";
var httpRequestData = new sn_auth.HttpRequestData();
httpRequestData.setEndpoint(endpoint);
httpRequestData.setService('s3');
httpRequestData.setRegion('us-east-1');
httpRequestData.setHttpMethod('put');
var content = "Action=SendMessage&MessageBody=This is a test message";
httpRequestData.setContent(content);
httpRequestData.addHeader('x-amz-acl', 'public-read' );
​

gs.info( "Header value is: " + httpRequestData.getHeader('x-amz-acl') );

Output:

Header value is: public-read

HttpRequestData - getHeaderMap()

Returns an object containing the headers included in the request.

NameTypeDescription
None  
TypeDescription
ObjectKey-value pairs that define all of the headers associated with the request. Each key-value pair includes these parts: - Key: String. Name of the header. - Value: String. Value of the header.
var endpoint= "https://third-party-endpoint";
var httpRequestData = new sn_auth.HttpRequestData();
httpRequestData.setEndpoint(endpoint);
httpRequestData.setService('s3');
httpRequestData.setRegion('us-east-1');
httpRequestData.setHttpMethod('put');
var content = "Action=SendMessage&MessageBody=This is a test message";
httpRequestData.setContent(content);
httpRequestData.addHeader('x-amz-acl', 'public-read' );
httpRequestData.addHeader('content-type', 'application/json' );

var map = httpRequestData.getHeaderMap();

for(var x in map) {
    var y = map[x]

    gs.info(x, y);
}

Output:

*** Script: x-amz-acl
*** Script: content-type

HttpRequestData - getHost()

Returns the host used in the request.

NameTypeDescription
None  
TypeDescription
StringHost used in the request.
var endpoint= "https://third-party-endpoint";
var httpRequestData = new sn_auth.HttpRequestData();
httpRequestData.setEndpoint(endpoint);
httpRequestData.setHost('myHost')
httpRequestData.setService('s3');
httpRequestData.setRegion('us-east-1');
httpRequestData.setHttpMethod('put');
var content = "Action=SendMessage&MessageBody=This is a test message";
httpRequestData.setContent(content);
httpRequestData.addHeader('x-amz-acl' , 'public-read' );

gs.info("Host is: " + httpRequestData.getHost());

Output:

Host is: myHost

HttpRequestData - getHttpMethod()

Returns the HTTP method used in the request.

NameTypeDescription
None  
TypeDescription
StringHTTP method used in the request.
var endpoint= "https://third-party-endpoint";
var httpRequestData = new sn_auth.HttpRequestData();
httpRequestData.setEndpoint(endpoint);
httpRequestData.setService('s3');
httpRequestData.setRegion('us-east-1');
httpRequestData.setHttpMethod('put');
var content = "Action=SendMessage&MessageBody=This is a test message";
httpRequestData.setContent(content);
httpRequestData.addHeader('x-amz-acl', 'public-read' );
​

gs.info("HTTP method is: " + httpRequestData.getHttpMethod());

Output:

HTTP method is: PUT

HttpRequestData - getQueryParam(String key)

Returns the value of the specified query parameter.

NameTypeDescription
keyStringName of the query parameter to get the value of.
TypeDescription
StringValue of the query parameter.
var endpoint= "https://third-party-endpoint";
var httpRequestData = new sn_auth.HttpRequestData();
httpRequestData.setEndpoint(endpoint);
httpRequestData.setService('s3');
httpRequestData.setRegion('us-east-1');
httpRequestData.setHttpMethod('put');
var content = "Action=SendMessage&MessageBody=This is a test message";
httpRequestData.setContent(content);
httpRequestData.addQueryParam('api_version', 'v2' );

gs.info("API version is: " + httpRequestData.getQueryParam('api_version'));

Output:

API version is: v2

HttpRequestData - getQueryParamMap()

Returns an object containing the query parameters included in the request.

NameTypeDescription
None  
TypeDescription
ObjectKey-value pairs that define the query parameters associated with the request. Each key-value pair includes these parts: - Key: String. Name of the query parameter. - Value: String. Value of the query parameter.
var endpoint= "https://third-party-endpoint";
var httpRequestData = new sn_auth.HttpRequestData();
httpRequestData.setEndpoint(endpoint);
httpRequestData.setService('s3');
httpRequestData.setRegion('us-east-1');
httpRequestData.setHttpMethod('put');
var content = "Action=SendMessage&MessageBody=This is a test message";
httpRequestData.setContent(content);
httpRequestData.addQueryParam('api_version', 'v2' );
httpRequestData.addQueryParam('limit', '1000' );
httpRequestData.addQueryParam('offset', '1' );


var map = httpRequestData.getQueryParamMap();
gs.info("api_version is: " + map['api_version']);

Output:

api_version is: v2

HttpRequestData - getRegion()

Returns the region for the request that will be used in signing.

NameTypeDescription
None  
TypeDescription
StringName of the region.
var endpoint= "https://third-party-endpoint";
var httpRequestData = new sn_auth.HttpRequestData();
httpRequestData.setEndpoint(endpoint);
httpRequestData.setService('s3');
httpRequestData.setRegion('us-east-1');
httpRequestData.setHttpMethod('put');
var content = "Action=SendMessage&MessageBody=This is a test message";
httpRequestData.setContent(content);

gs.info("Region is: " + httpRequestData.getRegion());

Output:

Region is: us-east-1

HttpRequestData - getService()

Returns the service defined in the request.

NameTypeDescription
None  
TypeDescription
StringService defined in the request.
var endpoint= "https://s3.amazonaws.com";
var httpRequestData = new sn_auth.HttpRequestData();
httpRequestData.setEndpoint(endpoint);
httpRequestData.setService('s3');

gs.info("Service is: " + httpRequestData.getService());

Output:

Service is: s3

HttpRequestData - setContent(String content)

Defines the content to send in the request.

Note: This method is not supported in script includes or MID server scripts.

NameTypeDescription
contentStringContent to send in the request.
TypeDescription
void 
var endpoint= "https://s3.amazonaws.com";
var httpRequestData = new sn_auth.HttpRequestData();
httpRequestData.setEndpoint(endpoint);
httpRequestData.setService('s3');
httpRequestData.setRegion('us-east-1');
httpRequestData.setHttpMethod('put');
var content = "This is a test message";
httpRequestData.setContent(content);

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.

NameTypeDescription
dateNumberThe difference between January 1, 1970 UTC and the date used to sign the request.Unit: Milliseconds
TypeDescription
void 
var endpoint= "https://s3.amazonaws.com";​
var httpRequestData = new sn_auth.HttpRequestData();​
httpRequestData.setEndpoint(endpoint);​
httpRequestData.addQueryParam("list-type", "2");​
httpRequestData.setService('s3');​
httpRequestData.setHttpMethod('get');
httpRequestData.setDate(1349333576093);

HttpRequestData - setDirective(String directive)

Defines whether to apply the signature to the request in a header or as a query parameter.

NameTypeDescription
directiveStringWhether to apply the signature to the header or as a query parameter. Values include: - `query`: Applies signature as a query parameter. - `header`: Applies signature to the request header. Default: header
TypeDescription
void 
var endpoint= "https://s3.amazonaws.com";​
var httpRequestData = new sn_auth.HttpRequestData();​
httpRequestData.setEndpoint(endpoint);​
httpRequestData.addQueryParam("list-type", "2");​
httpRequestData.setService('s3');​
httpRequestData.setHttpMethod('get');​
httpRequestData.setDirective("query");​

HttpRequestData - setEndpoint(String endpoint)

Defines the endpoint to send the request to.

NameTypeDescription
endpointStringEndpoint to send the request to. The endpoint can include query parameters, path, and version.
TypeDescription
void 
var endpoint="https://third-party-endpoint/path-parameters/version";

var httpRequestData = new sn_auth.HttpRequestData();
httpRequestData.setEndpoint(endpoint);

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.

NameTypeDescription
expiryNumberAmount of time before the signature expires.Unit: Seconds
TypeDescription
void 
var endpoint= "https://s3.amazonaws.com";​
var httpRequestData = new sn_auth.HttpRequestData();​
httpRequestData.setEndpoint(endpoint);​
httpRequestData.addQueryParam("list-type", "2");​
httpRequestData.setService('s3');​
httpRequestData.setHttpMethod('get');​
httpRequestData.setExpiry(300);​

HttpRequestData - setHost(String host)

Defines the host used in the request.

NameTypeDescription
hostStringName of the HTTP request host.
TypeDescription
void 
var endpoint= "https:third-party-endpoint";
var httpRequestData = new sn_auth.HttpRequestData();
httpRequestData.setEndpoint(endpoint);
httpRequestData.setHost('myHost')
httpRequestData.setService('s3');
httpRequestData.setRegion('us-east-1');
httpRequestData.setHttpMethod('put');
var content = "Action=SendMessage&MessageBody=This is a test message";
httpRequestData.setContent(content);
httpRequestData.addHeader('x-amz-acl', 'public-read' );

HttpRequestData - setHttpMethod(String httpMethod)

Sets the HTTP method to use in the request.

NameTypeDescription
httpMethodStringHTTP method to use in the request.
TypeDescription
void 
var endpoint= "https://third-party-endpoint";
var httpRequestData = new sn_auth.HttpRequestData();
httpRequestData.setEndpoint(endpoint);
httpRequestData.setService('s3');
httpRequestData.setRegion('us-east-1');
httpRequestData.setHttpMethod('put');

HttpRequestData - setRegion(String region)

Defines the region to use for the request in signing.

NameTypeDescription
regionStringThe region to use to sign the request. Available values are determined by the third-party API's requirements.
TypeDescription
void 
var endpoint= "https:third-party-endpoint";
var httpRequestData = new sn_auth.HttpRequestData();
httpRequestData.setEndpoint(endpoint);
httpRequestData.setService('s3');
httpRequestData.setRegion('us-east-1');
httpRequestData.setHttpMethod('put');
var content = "Action=SendMessage&MessageBody=This is a test message";
httpRequestData.setContent(content);

HttpRequestData - setService(String service)

Defines the service for the request.

NameTypeDescription
serviceStringThe service for the request.
TypeDescription
void 
var endpoint= "https://s3.amazonaws.com";
var httpRequestData = new sn_auth.HttpRequestData();
httpRequestData.setEndpoint(endpoint);
httpRequestData.setService('s3');