Connect SN platform from other systems
We all know the REST API service calls and the way of using OOB feature: REST API Explorer using SN. There are some instances where we can call/integrate SN from other systems/tools like Postman/ReactJS/Python etc. Of course we don’t have a biz requirement to consume SN services to fetch the data & use it (Eg: List of Incidents, call a SN module etc). We can connect SN from outside by using any of the below authentications.
- Basic – direct user/pwd in the API call and is not that secured
- OAUTH – 2 step process to connect and is secured option
- JWT – Secured option and I am still working on this.
For the above mentioned, I have taken Postman as the source to call SN API service (Email API) https://dev119117.service-now.com/api/now/v1/email
- Basic authentication: Used my user/pwd to connect my PDI and then send email from Postman
Request Body:
{
"to": ["ravi.pisupati@optum.com"],
"subject": "Hello There",
"text": "Test Message",
"html": "Test Message"
}
- OAUTH mechanism: 2 step process and we need to create an instance of “Application Registry” from SN and here are the details. After creating it, we capture the client id and client secret to pass them in the Postman call to generate the Access Token to make a secure call to send email using SN Email API
Select the first option from the list:
Fill all the mandatory fields and generate client id, client secret
Select auth type from Postman => OAuth2 and fill all the right hand side info to generate the access token
Capture the access token into a global variable using Postman script in the Tests tab
Call the SN Email API service and pass the request body elements data
Similarly I have used another UI framework – ReactJS to connect SN and fetch the list of Incidents in a browser. For this, I have learned few basics in ReactJS and learned about a package:axios for calling SN and rendering the incidents data on the browser 😊 Here are snapshot of this exercise and I can explain it to any of you guys are interested.
Here is the simple code written in VSC editor and we need to run few commands(npm) from the Terminal to launch the browser on http://localhost:3000. You can notice the highlighted SN PDI URL to pull the first 15 incidents using axios package from ReactJS
For this whole exercise, I have used Basic authentication and the user/pwd are stored in the .env file in ReactJS and here is the js file where I referenced.










