Skip to content

Commit 6ac8da9

Browse files
Create README.md
1 parent 8488230 commit 6ac8da9

File tree

1 file changed

+63
-0
lines changed
  • Server-Side Components/Script Includes/RestMessageUtils

1 file changed

+63
-0
lines changed
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
RestMessageUtils
2+
A utility Script Include for simplifying REST API calls in ServiceNow using sn_ws.RESTMessageV2.
3+
Features
4+
5+
Supports dynamic or named REST messages.
6+
Easily set headers, query parameters, and request body.
7+
Supports Basic Auth, Auth Profiles, and API Key authentication.
8+
Optional MID Server configuration.
9+
Handles variable substitution.
10+
Centralized error handling with gs.error() logging.
11+
Designed for use in Script Includes, Business Rules, or Scripted REST APIs.
12+
Lightweight and reusable for multiple integrations.
13+
14+
Object Structure
15+
/*
16+
ObjectStructure = {
17+
endPoint: 'enpoint',
18+
httpMethod: 'Add Method',
19+
queryParams: {
20+
key1: 'value',
21+
key2: 'value'
22+
},
23+
requestHeaders: {
24+
25+
},
26+
authType: 'CHOICES among [BasicCreds,BasicAuthProfile,APIKEY]',
27+
authProfile: 'sysid of auth profile if authtype is selected as BasicAuthProfile',
28+
userName: 'userName',
29+
pasword: 'password',
30+
midServer: 'midServer',
31+
32+
}
33+
*/
34+
35+
Example Usage
36+
/*
37+
var obj = {
38+
endPoint: 'https://dev204127.service-now.com/api/now/table/problem',
39+
queryParams: {
40+
sysparm_query: 'active=true',
41+
sysparm_limit: 2,
42+
sysparm_fields: 'number,short_description'
43+
},
44+
httpMethod: 'POST',
45+
authType: 'BasicCreds',
46+
userName: 'admin',
47+
password: gs.getProperty('dev204127.admin.password'),
48+
requestHeaders: {
49+
Accept: 'Application/JSON'
50+
},
51+
52+
53+
};
54+
var resp = new RestMessageUtils(obj, 'Test RestMessage Utils', 'Default GET').execute();
55+
56+
gs.print(resp.getBody())
57+
*/
58+
59+
60+
61+
62+
63+

0 commit comments

Comments
 (0)