ServiceNow CLI - an interesting feature to play with SN using REST API calls

 The ServiceNow CLI is a command-line interface that lets us to perform instance operations from our local system. We can extend the CLI to include new commands that meet the application's needs.

Benefits

The ServiceNow CLI lets us to:

  • Perform basic CRUD operations on records in SN instance.
  • Develop custom components and deploy them to SN instance to personalize a UI.
  • Create custom commands that enable to manage custom applications from the command line.
  • Use the ServiceNow CLI in scripts to simplify setup tasks and operational activities.

 

Architecture

Commands are stored in a table on the instance where we are connected to. When the ServiceNow CLI connects to the instance, it receives all the available commands supported by that instance. Commands map to a REST endpoint that executes asynchronously. 














Activating ServiceNow CLI in Windows machine:

 

Here are the steps I followed to run this functionality successfully from my personal laptop using my PDI

 

  1. Download the CLI client from SN store and here is the link: https://store.servicenow.com/sn_appstore_store.do#!/store/application/9085854adbb52810122156a8dc961910/1.1.0?referer=%2Fstore%2Fsearch%3Flistingtype%3Dallintegrations%25253Bancillary_app%25253Bcertified_apps%25253Bcontent%25253Bindustry_solution%25253Boem%25253Butility%25253Btemplate%26q%3DCLI&sl=sh
  2. Make sure to have the CLI Metadata plugin installed in the SN instance.














  1. Make sure to have the SNC Client path should be set in the PATH variable (Environment) [Eg:C:\Users\urspv\.snc]


SN CLI Path and profile config setup:

This is the path where we have all the necessary files are useful to run this CLI functionality













This is the command to run after CLI installation done from the store. With this we are creating config.json file and /default folder where we have the commands.json file mentioned below
































Commands JSON file to connect to the SN instance using REST API service call from SN CLI client on the command line:




















Sample commands from command line using "snc record" command:

  1. This is for list of all incidents from SN PDI instance after successful REST API call done using the below command




















  1. This is to create a new incident in SN instance using REST service call on table API





















  1. End result after adding a new record from the command line












References:

1) www.Google.com

2) https://docs.servicenow.com/

3) https://developer.servicenow.com/

4) https://store.servicenow.com/sn_appstore_store.do#!/store/home

5) https://github.com/ServiceNow/servicenow-cli















Popular posts from this blog

Connecting Claude to Pega Infinity 25.1.3 via MCP — Step-by-Step

itextpdf API to generate PDF doc from an image file using Pega PE

Understanding of Hugging Face platform for AI/ML platform