📁 Scripted REST API (Developer Documentation) Flashcards

1
Q

When do Security, Content Negotiation, and Documentation sections become available in the context of ServiceNow Scripted REST API’s?

A

They become available after saving for the first time.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What is something important to remember about Scripted REST API Access Control checks?

A

A requesting user must satisfy at least one of the Access Controls, but it is not necessary to satisfy all selected Access Controls

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What Access Control type do Access Controls for Scripted REST APIs have?

A

REST_Endpoint

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

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?

A

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.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What does the Content Negotiation section of a Scripted REST API define?

A

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

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

What does the Documentation section do in the context of Scripted REST APIs?

A

Helps to direct users, with links, towards ServiceNow documentation that can better explain the APIs and methods used.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

What does a REST request header contain?
&
What are some commonly used ones?

A

REST request headers contain parameters (metadata) that defines the HTTP(S) interaction.
&
Some commonly used ones include
- Authorization
- Accept
- Content-Type

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

What do Query parameters do in the context of REST request headers?

A

Query parameters control what information developers using the API can pass in the API request URL.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

What are the formatting conventions surrounding Query parameter names in Scripted REST APIs?

A

By convention, query parameter names are lowercase and use underscores in place of spaces.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

What string do many query parameters in baseline ServiceNow Scripted REST APIs start with?

A

sysparm_

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

A REST API is a collection of REST resources.
What are REST resources?

A

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

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

Where are Scripted REST API resources found and created?

A

There is a Resources related list on the Scripted REST API entry.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

What is something important to remember about Scripted REST API Resources in regards to Security, Content, and Documentation sections?

A

Resources inherit settings from the Scripted REST API but these setting can be overridden.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

Request headers are defined in the Scripted REST API, but how are they associated with Scripted REST API Resources?

A

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.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

Query parameters are defined in the Scripted REST API, but how are they associated with Scripted REST API Resources?

A

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.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

What does the RESTAPIRequest API allow developers to do?

A

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.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
17
Q

What are the properties of the request object in the context of the RESTAPIRequest API?

A
  • body
  • pathParams
  • queryParams
  • queryString
  • uri
  • url
  • headers
  • getHeader()
  • getSupportedResponseContentTypes()
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
18
Q

What is a resource script?

A

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.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
19
Q

When working with the RESTAPIRequest API, what does the body object do?

A

It provides access to the request body.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
20
Q

When working with the RESTAPIRequest API, what does the pathParams object do?

A

Allows script access to path parameters passed in the requested URL. The available path parameters are determined by the Scripted REST Service resources.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
21
Q

When working with the RESTAPIRequest API, what does the queryParams object do?

A

Allows script access to the query parameters from the web service request.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
22
Q

When working with the RESTAPIRequest API, what does the queryString string contains ?

A

It contains the entire query added to the endpoint URI.

23
Q

When working with the RESTAPIRequest API, what does the URI string contain?

A

It contains the request URI, excluding domain information.

24
Q

When working with the RESTAPIRequest API, what does the URL string contain?.

A

It contains the entire request URL.

25
Q

When working with the RESTAPIRequest API, what does the headers object do?

A

It contains all header property value pairs from the request.

26
Q

What class is the getHeader() method associated with?

A

RESTAPIRequest

27
Q

What does the getHeader() method do?

A

It returns a string containing the value of a specific header from the web service request.

28
Q

What class is the getSupportedResponseContentTypes() method?

A

RESTAPIRequest

29
Q

What does the getSupportedResponseContentTypes() method do?

A

Returns an array of string values where each string is a content type, such as application/json

30
Q

What does the RESTAPIRequestBody API allow developers to do?

A

Allows developers to access the body content of a scripted REST API request. The request.body object is instantiated automatically.

31
Q

What class is the hasNext() method associated with?

A

RESTAPIRequestBody

32
Q

What does the hasNext() method do?

A

Returns true if the request body contains another entry

33
Q

What class is the nextEntry() method associated with?

A

RESTAPIRequestBody

34
Q

What does the nextEntry() method do?

A

Retrieves one entry from the request body as a script object.

35
Q

What does the RESTAPIResponse API allow developers to do?

A

Allows developers to build a response to a scripted REST API request. The response object is instantiated automatically.

36
Q

In the context of the RESTAPIRequestBody API, what is dataStream?

A

dataStream: The content of the request body as a stream.

37
Q

In the context of the RESTAPIRequestBody API, what is dataString?

A

dataString: The content of the request body as a string.

38
Q

What class is the getStreamWriter() method associated with?

A

RESTAPIResponse

39
Q

What does the getStreamWriter() method do?

A

Used to write directly to the response stream.

40
Q

What class is the setBody() method associated with?

A

RESTAPIResponse

41
Q

What does the setBody() method do?

A

Creates the response body, as a javascript object. The body content is automatically serialized to JSON or XML depending on the value of the Accept header, passed in the request.

42
Q

What class is the setContentType() method associated with?

A

RESTAPIResponse

43
Q

What does the setContentType() method do?

A

Assigns a value, such as application/json, to the Content-Type header in the web service response.

44
Q

What class is the setError() method associated with?

A

RESTAPIResponse

45
Q

What does the setError() method do?

A

Sets the properties of the response error object when an error is returned.

46
Q

What class is the setHeader() method associated with?

A

RESTAPIResponse

47
Q

What does the setHeader() method do?

A

Assigns a value to a REST service response header.

48
Q

What class is the setHeaders() method associated with?

A

RESTAPIResponse

49
Q

What does the setHeaders() method do?

A

Sets the headers for the web service response

50
Q

What class is the setLocation() method associated with?

A

RESTAPIResponse

51
Q

What does the setLocation() method do?

A

Assigns a value to the Location header in the web service response.

52
Q

What class is the setStatus() method associated with?

A

RESTAPIResponse

53
Q

What does the setStatus() method do?

A

Sets the status code to send in the response, such as 200 to indicated success.

54
Q

What are some important things to remember about resource scripts?

A
  • The process function is self-invoking
  • The request and response objects are automatically instantiated
  • Access controls apply to Scripted REST APIs. The user making the request through the APIs authentication must have access to the requested information.