Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions Scripted REST Api/CMDB API/CmdbApi.js
Original file line number Diff line number Diff line change
Expand Up @@ -299,6 +299,27 @@ createCiRelationship: function() {
sysparm_limit: 100
});
},

/**
* Retrieves Configuration Items (CIs) based on the specified CI type.
* Mapped to GET /cis/{ci_type}
* @returns {GlideRecordStream} A stream of GlideRecord objects representing the CIs.
* @throws {BadRequestError} If an invalid CI type is provided.
*/
getCis: function() {
var self = this;

var ciType = self.getPathParam('ci_type', '');

if (!self._isValidCiType(ciType)) {
return sn_ws_err.BadRequestError('Invalid CI Type provided:' + ciType);
}

return self._getGrResultStream(ciType, null, {
sysparm_limit: 100
});

},

/**
* Determine the type of source ID.
Expand Down
6 changes: 6 additions & 0 deletions Scripted REST Api/CMDB API/RetrieveCis.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
(function process(/*RESTAPIRequest*/ request, /*RESTAPIResponse*/ response) {

// implement resource here
return new CmdbApi(request, response).getCis();

})(request, response);
15 changes: 15 additions & 0 deletions Scripted REST Api/CMDB API/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ Table of Contents
4. Delete CI Relationship
5. Retrieve CI Group
6. Retrieve CI Relationship types
7. Retrieve CIs

1. Create CIs
This API is designed to create Configuration Items (CIs).
Expand Down Expand Up @@ -99,3 +100,17 @@ Table of Contents
Response:
Status Code: 200 OK
Response Body: Details of CI Relationship types

7. Retrieve CIs
Scripted REST API Resource contains a ServiceNow script that implements a function for retrieving Configuration Items (CIs) based on a specified CI type.
Request Details:
Type: HTTP
Method: GET
URI: https://<service-now-domain>.service-now.com/api/cis/{ci_type}
Headers:
Accept: application/json
Content-Type: application/json
Request Body: NA
Response:
Status Code: 200 OK
Response Body: JSON Details of CIs based on the given type