📁 Scripted REST API (Developer Documentation) Flashcards
When do Security, Content Negotiation, and Documentation sections become available in the context of ServiceNow Scripted REST API’s?
They become available after saving for the first time.
What is something important to remember about Scripted REST API Access Control checks?
A requesting user must satisfy at least one of the Access Controls, but it is not necessary to satisfy all selected Access Controls
What Access Control type do Access Controls for Scripted REST APIs have?
REST_Endpoint
What is the default Access Control applied to all new Scripted REST APIs?
& Who does this default Access Control deny access to the Scripted REST API?
Scripted REST External Default
Developers can remove the default and/or add Access Controls of their choice.
& The default Access Control denies access to the Scripted REST API to any user with the snc_external role.
What does the Content Negotiation section of a Scripted REST API define?
The Content Negotiation section defines the supported request and response formats.
The default for the request and response is to allow:
- application/json
- application/xml
- text/xml
What does the Documentation section do in the context of Scripted REST APIs?
Helps to direct users, with links, towards ServiceNow documentation that can better explain the APIs and methods used.
What does a REST request header contain?
&
What are some commonly used ones?
REST request headers contain parameters (metadata) that defines the HTTP(S) interaction.
&
Some commonly used ones include
- Authorization
- Accept
- Content-Type
What do Query parameters do in the context of REST request headers?
Query parameters control what information developers using the API can pass in the API request URL.
What are the formatting conventions surrounding Query parameter names in Scripted REST APIs?
By convention, query parameter names are lowercase and use underscores in place of spaces.
What string do many query parameters in baseline ServiceNow Scripted REST APIs start with?
sysparm_
A REST API is a collection of REST resources.
What are REST resources?
REST resources are unique data representations that have at least one URI
Resources are typically a set of related information, such as a record, changes to a record, or calculations based on records. An HTTP method defines each resource
GET, POST, PUT, PATCH, DELETE
Where are Scripted REST API resources found and created?
There is a Resources related list on the Scripted REST API entry.
What is something important to remember about Scripted REST API Resources in regards to Security, Content, and Documentation sections?
Resources inherit settings from the Scripted REST API but these setting can be overridden.
Request headers are defined in the Scripted REST API, but how are they associated with Scripted REST API Resources?
They are associated with resources in the resource definitions.
To associate a request header, scroll to the Request Header Associations related list. Click the New button. Use the API request header field Search button to select a request header to associate with the resource.
Query parameters are defined in the Scripted REST API, but how are they associated with Scripted REST API Resources?
To associate a query parameter, scroll to the Query Parameter Associations related list. Click the new button. Use the API query parameter field Search button to select a query parameter to associate with the resource.
What does the RESTAPIRequest API allow developers to do?
The RESTAPIRequest API allows developers to access data from the request. The request object is automatically instantiated from the RESTAPIRequest class and passed to the process function in the Scripted REST API script.
What are the properties of the request object in the context of the RESTAPIRequest API?
- body
- pathParams
- queryParams
- queryString
- uri
- url
- headers
- getHeader()
- getSupportedResponseContentTypes()
What is a resource script?
A server-side JavaScript that creates and populates properties on the response object.
The response object is returned to the application that invoked the resource.
When working with the RESTAPIRequest API, what does the body object do?
It provides access to the request body.
When working with the RESTAPIRequest API, what does the pathParams object do?
Allows script access to path parameters passed in the requested URL. The available path parameters are determined by the Scripted REST Service resources.
When working with the RESTAPIRequest API, what does the queryParams object do?
Allows script access to the query parameters from the web service request.