{"revision":"c10276e953456835cdbb1f3a60d58ae1980be353","document":{"id":1104,"path":"api-reference/server-api-reference/c_ScriptableServiceRequest.md","title":"RESTAPIRequest - Scoped, Global","bundle":null,"doc_type":null,"release":"australia","body":"\n# RESTAPIRequest - Scoped, Global\n\nThe RESTAPIRequest API provides methods that allow you to access scripted REST API request details in scripts.\n\nThis API runs in the `sn_ws` namespace.\n\n**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.\n\n**Parent Topic:**[Server API reference](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/api-reference/server-api-reference/api-server.md)\n\n## RESTAPIRequest - body\n\nThe body of the request.\n\n|Name|Type|Description|\n|----|----|-----------|\n|body|[RESTAPIRequestBody](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/api-reference/server-api-reference/c_ScriptableServiceRequestBody.md)|The body of the request. You can access data from the body object using the RESTAPIRequestBody API.|\n\n```\nvar requestBody = request.body // Returns instance of RESTAPIRequestBody\n```\n\n## RESTAPIRequest - getHeader\\(String header\\)\n\nReturns the value of a specific header from the web service request.\n\n|Name|Type|Description|\n|----|----|-----------|\n|header|String|The name of the header, such as **accept** or **content-type**.|\n\n|Type|Description|\n|----|-----------|\n|String|The value of the specified header.|\n\n```\nvar acceptHeader = request.getHeader('accept');\n```\n\n## RESTAPIRequest - getSupportedResponseContentTypes\\(\\)\n\nGet the content types specified in the request Accept header.\n\n|Name|Type|Description|\n|----|----|-----------|\n|None| | |\n\n|Type|Description|\n|----|-----------|\n|Array|An array of string values where each string is a content type, such as application/json.|\n\n## RESTAPIRequest - headers\n\nAll headers from the request.\n\n|Name|Type|Description|\n|----|----|-----------|\n|headers|object|All headers from the request, and their values.|\n\n```\nvar headers = request.headers; \nvar acceptHeader = headers.Accept;\nvar myCustomHeader = headers.myCustom; \nvar specialHeader = headers['special - header'];\n```\n\n## RESTAPIRequest - pathParams\n\nThe path parameters passed in the request URI.\n\n|Name|Type|Description|\n|----|----|-----------|\n|pathParams|Object|The path parameters as a script object. Available path parameters depend on the web service configuration.|\n\nIn 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`.\n\n```\nvar pathParams = request.pathParams; \nvar tableName = pathParams.tableName; //'myApp_table' \nvar id = pathParams.id; //'1234'\n```\n\n## RESTAPIRequest - queryParams\n\nThe query parameters from the web service request.\n\n|Name|Type|Description|\n|----|----|-----------|\n|queryParams|Array|The query parameters from the web service request.|\n\nIn this example, the request being processed uses this URL: `https://<instance_rest_endpoint>?active=false&name=now`. Note the **active** and **name** parameters.\n\n```\nvar queryParams = request.queryParams; \nvar isActiveQuery = queryParams.active; // [false] \nvar nameQueryVal = queryParams.name; // ['now']\n```\n\n## RESTAPIRequest - queryString\n\nThe entire query added to the endpoint URI.\n\n|Name|Type|Description|\n|----|----|-----------|\n|queryString|String|The entire query for the request.|\n\nIn this example, the request being processed uses this URL: `https://<instance_rest_endpoint>?active=false&name=now`. Note the query `active=false&name=now`.\n\n```\nvar query = request.queryString; //\"active=false&name=now\"\n```\n\n## RESTAPIRequest - uri\n\nThe request URI, excluding domain information.\n\n|Name|Type|Description|\n|----|----|-----------|\n|uri|String|The request URI, excluding domain information.|\n\nIn this example, the request being processed uses this URL: `https://instance.service-now.com/api/now/table/myTable?active=false&name=now`.\n\n```\nvar query = request.uri; //\"api/now/table/myTable\"\n```\n\n## RESTAPIRequest - url\n\nThe entire request URL.\n\n|Name|Type|Description|\n|----|----|-----------|\n|url|String|The entire request URL.|\n\nIn this example, the request being processed uses this URL: `https://instance.service-now.com/api/now/table/myTable?active=false&name=now`.\n\n```\nvar query = request.url; //\"https://instance.service-now.com/api/now/table/myTable?active=false&name=now\"\n```\n\n"}}