---
sourceDocument: Xanadu API Reference
sourceDocumentLink: https://servicenow-prod.fluidtopics.net/r/xanadu/api-reference

 Release :

    - xanadu

ft:locale :

    - en-US

ft:publication_title :

    - Xanadu API Reference

ft:clusterId :

    - crapiref

bundleId :

    - crapiref

workflow :

    - Creator


---

# RESTAPIRequest - Scoped, Global

# RESTAPIRequest - Scoped, Global {#ariaid-title1}

* Release version: Xanadu
* 
* Updated August 1, 2024
* 
* ![](https://www.servicenow.com/docs/portal-asset/ico-clock) 2 minutes to read

The RESTAPIRequest API provides methods that allow you to access scripted REST API request details in scripts.

This API runs in the `sn_ws` namespace.  
Note:  
You cannot instantiate objects of this type. Objects of this type are created automatically and are accessible only in scripted REST API resource scripts.

## RESTAPIRequest - body {#ariaid-title2}

The body of the request.
{#r_SSR_body__table_a3m_rt1_sr__entry__3}

| Name | Type | Description |
|-|-|-|
| body | [RESTAPIRequestBody](https://servicenow-prod.fluidtopics.net/YfSTmH7E4~pHEYs7TG2bQQ#c_ScriptableServiceRequestBody "The RESTAPIRequestBody API provides methods that allow you to access the body content of a scripted REST API request in scripts.") | The body of the request. You can access data from the body object using the RESTAPIRequestBody API. |
[Table 1. Field]

{#r_SSR_body__table_a3m_rt1_sr}  

    var requestBody = request.body // Returns instance of RESTAPIRequestBody

## RESTAPIRequest - getHeader(String header) {#ariaid-title3}

Returns the value of a specific header from the web service request.
{#r_SSR-getHeader_String__table_q32_q2r_qr__entry__3}

| Name | Type | Description |
|-|-|-|
| header | String | The name of the header, such as accept or content-type. |
[Table 2. Parameters]

{#r_SSR-getHeader_String__table_q32_q2r_qr} {#r_SSR-getHeader_String__table_r32_q2r_qr__entry__2}

| Type | Description |
|-|-|
| String | The value of the specified header. |
[Table 3. Returns]

{#r_SSR-getHeader_String__table_r32_q2r_qr}  

    var acceptHeader = request.getHeader('accept');

## RESTAPIRequest - getSupportedResponseContentTypes() {#ariaid-title4}

Get the content types specified in the request Accept header.
{#r_SSR-getSupportedRespContentTypes__table_rtm_qg3_zs__entry__3}

| Name | Type | Description |
|-|-|-|
| None |   |   |
[Table 4. Parameters]

{#r_SSR-getSupportedRespContentTypes__table_rtm_qg3_zs} {#r_SSR-getSupportedRespContentTypes__table_stm_qg3_zs__entry__2}

| Type | Description |
|-|-|
| Array | An array of string values where each string is a content type, such as application/json. |
[Table 5. Returns]

{#r_SSR-getSupportedRespContentTypes__table_stm_qg3_zs}

## RESTAPIRequest - headers {#ariaid-title5}

All headers from the request.
{#r_SSR_headers__table_zmm_3s1_sr__entry__3}

| Name | Type | Description |
|-|-|-|
| headers | object | All headers from the request, and their values. |
[Table 6. Field]

{#r_SSR_headers__table_zmm_3s1_sr}  

    var headers = request.headers; 
    var acceptHeader = headers.Accept;
    var myCustomHeader = headers.myCustom; 
    var specialHeader = headers['special - header'];

## RESTAPIRequest - pathParams {#ariaid-title6}

The path parameters passed in the request URI.
{#r_SSR_pathParams__table_zsf_jr1_sr__entry__3}

| Name | Type | Description |
|-|-|-|
| pathParams | Object | The path parameters as a script object. Available path parameters depend on the web service configuration. |
[Table 7. Field]

{#r_SSR_pathParams__table_zsf_jr1_sr}  
In this example, the scripted REST API endpoint follows this format:
https://instance.service-now.com/api/now/myservice/{tableName}/{id}.
The request being processed uses this URL:
https://instance.service-now.com/api/now/myservice/myApp_table/1234.

    var pathParams = request.pathParams; 
    var tableName = pathParams.tableName; //'myApp_table' 
    var id = pathParams.id; //'1234'

## RESTAPIRequest - queryParams {#ariaid-title7}

The query parameters from the web service request.
{#r_SSR_queryParams__table_gzw_yg5_rr__entry__3}

| Name | Type | Description |
|-|-|-|
| queryParams | Array | The query parameters from the web service request. |
[Table 8. Field]

{#r_SSR_queryParams__table_gzw_yg5_rr}  
In this example, the request being processed uses this URL:
https://\<instance_rest_endpoint\>?active=false\&name=now. Note
the active and name parameters.

    var queryParams = request.queryParams; 
    var isActiveQuery = queryParams.active; // [false] 
    var nameQueryVal = queryParams.name; // ['now']

## RESTAPIRequest - queryString {#ariaid-title8}

The entire query added to the endpoint URI.
{#r_SSR_queryString__table_zwx_5q1_sr__entry__3}

| Name | Type | Description |
|-|-|-|
| queryString | String | The entire query for the request. |
[Table 9. Field]

{#r_SSR_queryString__table_zwx_5q1_sr}  
In this example, the request being processed uses this URL:
https://\<instance_rest_endpoint\>?active=false\&name=now. Note
the query `active=false&name=now`.

    var query = request.queryString; //"active=false&name=now"

## RESTAPIRequest - uri {#ariaid-title9}

The request URI, excluding domain information.
{#r_SSR_uri__table_h5d_ct1_sr__entry__3}

| Name | Type | Description |
|-|-|-|
| uri | String | The request URI, excluding domain information. |
[Table 10. Field]

{#r_SSR_uri__table_h5d_ct1_sr}  
In this example, the request being processed uses this URL:
https://instance.service-now.com/api/now/table/myTable?active=false\&name=now.

    var query = request.uri; //"api/now/table/myTable"

## RESTAPIRequest - url {#ariaid-title10}

The entire request URL.
{#r_SSR_url__table_zdq_qs1_sr__entry__3}

| Name | Type | Description |
|-|-|-|
| url | String | The entire request URL. |
[Table 11. Field]

{#r_SSR_url__table_zdq_qs1_sr}  
In this example, the request being processed uses this URL:
https://instance.service-now.com/api/now/table/myTable?active=false\&name=now.

    var query = request.url; //"https://instance.service-now.com/api/now/table/myTable?active=false&name=now"


