logo

NJP

6. ServiceNow REST API Explorer

Import · May 21, 2021 · video

so the next use case i want to demonstrate is you've integrated with another application we're making rest calls from the service now from our flows and our sub flows to create information retrieve information but what if those applications need to talk to servicenow to initiate a workflow to create a record to retrieve the list of records that's what i want to show you how easy that is what i have up is the rest api explorer this is how we can look at servicenow's rest endpoints assemble our request and then move that code over to whatever application it is and even test them to make sure that they work and what my favorite thing is see what the response is going to look like how it's going to be formatted so that i can anticipate and process that response in the third party application however i need to i have all my application scopes like we saw earlier so we in our previous demo we did the jira spoke so you can see i've got some callbacks that are predefined here for jira to call back to servicenow as part of that spoke in this example i'm going to use the use case of you want to get a list of accounts from the service now because you need to use them in some other application so we'll actually use the table api this is looking at table level data within servicenow and we'll stick with the latest version you can see that for that api i have the ability to create retrieve modify delete and update records within servicenow there's some best practices around how and when you should do that and when you should do staging tables and stuff like that we won't get into that here but i'm actually just going to retrieve a list of records from this table so we're going to do again the table name that we're going to do is customer i want a list of customer accounts to use elsewhere and another application as part of whatever larger workflow that i'm working on so i specify the table i'm looking at now here's the query parameters i can specify for this particular uh rest request i'm going to go ahead and say all for this one and we will do true to exclude links to reference fields and i want to suppress the pagination header and i'm going to limit this to 10 results so you can see more than one result coming back now if i wanted to add additional query parameters i could do that here if i wanted to add additional headers i could do that there if i wanted to change the format of what the receiving system receives from json to xml or plain text xml we can do that there i'm going to leave them both as json that's the one i'm most familiar with so cool button number one send i can go ahead and execute that rest request it's going to show me what the get request was how the headers looked and then what the response was this one actually worked yay i got a 200 here's the headers that came back and there's the response body so this is what that application that you're configuring is going to receive from servicenow when it makes this rest call so we've got everything we need to test and troubleshoot make sure that the data that's coming from servicenow is what we're expecting in that other application now speaking of other applications what if i you know need to write code in order to call that well if i have python i can click this link and it will pre-configure the python code for me to copy and paste to that application let's check this out so look at the url that's coming in that particular code snippet if i scroll to the right you can see there that my parameters that i added all and i think true and false and then there's the limit of 10 for that particular one so all that's ready to go over to my application i just copy and paste um or select and control c to copy and i can put that in that other application i've also got ruby javascript perl powershell again i just click on them there's my code copy paste and you're off so again servicenow makes this really easy to talk to other applications retrieve information from other applications and for those other applications to do create read update delete operations within servicenow so to bring all this back what you've just seen we saw that there's a full integrated development environment within servicenow to write applications on the platform those could include scripts server-side scripts rest calls to other systems we can define actions within the flow designer there's pre-built hundreds of actions that come from integration hub spokes depending on what access level you have there's four different tiers and you can access those we can use those actions as part of subflows subflows are reusable flows that we can add to larger workflows or flows within servicenow so again we build an action once we reuse it we build a subflow once we reuse it and reuse it many times and you can actually you know do some things where even security wise certain people can't see things between those subflows and actions so that the people who are creating general workflows don't have access to maybe protected information then you have the ability to write your own rest actions you can make your own scripts that go in there or you don't have to use scripts you can drag and drop the data pills you can make the rest calls and send those to whatever third party or custom and homegrown applications that you have and then lastly we can get information into and out of servicenow using the servicenow rest api and the rest api explorer to get our rest queries or our rest calls formatted properly understand what the responses are going to be and able to code our applications quickly and easily using the provided code snippets i hope this was helpful thank you so much for your time

View original source

https://www.youtube.com/watch?v=z0sgm5mFVwo