The Now Platform® Washington DC release is live. Watch now!

Help
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

TechNow Ep 49 | Faster Integrations with the REST API Explorer

Chuck Tomasi
ServiceNow Employee
ServiceNow Employee

expert-logo-2.png

Find out how the REST API Explorer can speed up your integrations development. While we've used the REST API Explorer as a debugging tool in several previous episodes, we've never really sat down and shown you what it can do.

Quick tip: Preparing your scripts for multiple languages

 
(Be sure to change your YouTube Setting to 720HD)

Ask your questions below on this discussion page.

And Please Let our Experts know how they've helped! Comment Below!

GitHub repository used in the quick tip: https://github.com/chucktomasi/TN49-QT.git

Originally aired April 26, 2018


Featured Experts

find_real_file.pngChuck Tomasi is a Sr. Technical Program Marketing Manager for ServiceNow.   He is a computer science major with over 35 years of IT experience. As a former ServiceNow customer, Chuck won the first Innovation of the Year Award at Knowledge 10. Since joining ServiceNow in 2010 as a Technical Consultant, he has done many large scale ITSM implementations and custom applications, acted as an adjunct instructor for Education Services, created and lead the Technical Best Practices program, makes appearances on Live Coding Happy Hour, created dozens of fit for purpose custom applications, and co-hosts the ServiceNow series "TechNow".

find_real_file.pngDave Slusher has been developing software for 20 years for companies such as Intel, Orbitz, Dell Secureworks and many startups lost to history. He has been with ServiceNow for two years, first in Expert Services and now as the Developer Evangelist for the developer community and portal. He earned his BS from Georgia Tech and his MS in Computer Science from the University of Louisiana - Lafayette.

find_real_file.pngKreg Steppe is a Senior Curriculum Developer within ServiceNow developing and supporting cloud training infrastructure. He specializes in developing integration solutions, automating repeatable processes and Cloud Management in ITOM. Kreg's prior experience includes operating his own ISP, developing web applications in PHP, network integration, managing network support, Application Development on cloud based networks, DNS and email server maintenance. He is a Linux enthusiast and enjoys Photography.


10 REPLIES 10

Jace Benson
Mega Sage

Thanks for sharing this Chuck!

Chuck Tomasi
ServiceNow Employee
ServiceNow Employee

Below are the questions and answers from the session.

 

Where do I associate the key with the 'REST IPA' item ? -- Nhan Tran
I'm not sure what key are you are referring to here. -- Chuck Tomasi

Can we now use the REST API for client-side scripts without the end user being prompted to re-auth? -- Andy Hopper
It depends how you set up authorization. That's not really within the scope of what we're talking about with regards to the REST API Explorer today -- Chuck Tomasi

Old versions allowed alternate authentication. This was valuable troubleshooting, will it come back? -- Aaron Wilson
I don't have any information at this time. If I hear something, I'll let you know. -- Chuck Tomasi

where does the security come from if someone used the API without being logged into ServiceNow at all? -- Daniel Nickelson
I think we just answered that one live. -- Chuck Tomasi

so, revisiting security, if a user has access to edit/delete records in the system, they can do so with REST APIs out of the box, so we may have folks 'playing' with REST APIs on Production? -- Jonah Piascik
You may have, but you can track that with built in logs if you think that's a problem. Most organizations don't have an issue with that because there are few people who even know what to do with a REST API (ServiceNow included.) -- Chuck Tomasi

will questions /answers be posted perhaps later? -- Chris Nick
Hi Chris. I will check with the team, but we can publish a transcript of the Q&A on Community. Stay tuned.... -- 

I am getting an erro when trying to reach your survey -- Kim Marshall
I'm sorry. It apears to be working for others. let us know if it continues to be an issue after trying different browers, computers, or network access. -- Chuck Tomasi

What was that sourcery to generate your saved code? You typed in something like "t342" and then it just loaded your script. -- Tony Peraza
Text Expander -- Kreg Steppe

do table business rules run on Table API Inserts? -- duane more
Yes, BRs are run on REST API operations including Insert. -- Chuck Tomasi

I am trying to grab data from a table in a teamspace . can you give me the expression to do this? I am not an admn nor a developer. -- Edgar Punay
Unfortunately we wont have time on this session to in to that depth. I recommend posing the question on our community. -- Chuck Tomasi

Once I get the code executed, can we specifiy where the generated file go? -- Edgar Punay
That's really up to you, as the author of the third party app accessing ServiceNow. -- Chuck Tomasi

If i am using a third party tool that will be using REST API to connect to Service Now to retrieve data, what will be the script look like : is that the GET URL ? -- Sunil Epari
Sorry, I don't understand the question. -- Chuck Tomasi

can you suppress the typical UI update behavior as you can with the glide system? (i.e) rec.autoSysFields(false); rec.setWorkflow(false); -- Chance Robinson
Short answer yes - however it's not part of the REST API Explorer -- Chuck Tomasi

thanks! -- Chris Brown


Thank you. Great session. Hopefully we can have more of these. Maybe see you at one of the REST sessions at Knowledge. -- James Higgins
You're welcome -- Chuck Tomasi

Linux is a hobby ? -- Nhan Tran
Yes and no. It is business and pleasure for me. -- Kreg Steppe

If you specify a list of field names in sysparm_fields parameter... can you leverage dot walking to pull in attributes from reference fields? -- Tim Towstego
Yes, you can enter dot-walk fields. They are not available from the slushbucket. -- Chuck Tomasi

I am most interested in a POST if possible to see that example -- William Coursen
Thank you. Dave has that covered. -- Chuck Tomasi

Is there a way to get all the fields - not just selected fields? -- richard mauchline
Yes, it returns all fields by default. -- Chuck Tomasi

Is there any limitations when using REST API with SSO through SAML? -- Saamer Saad
None that I know of. -- Chuck Tomasi

Is the Rest API extended to include tables created with portal applications? -- Michael Keyes
All tables in ServiceNow automatically have a REST API available to access them. -- Chuck Tomasi

When a call comes in, what is the preferred method? For inbound scripted REST APIs that push to a logging table, should I use the scipt on the inbound record to push directly to the table, or push to a import set and run a transform from there? -- Jonathan Yates
Ideally, import sets should be used, but not always necessary. I wouldn't doa scripted REST API to the import set as you have full control to do the transform/cleanup there. Seems a bit redundant. -- Chuck Tomasi

Hello Everyone! -- Nate Engstrom
Hello! -- Kreg Steppe

GET Method - Can we pull the record with Incident number not using Sys_id? -- Narasimha Rao
If you code it right, yes you can. -- Kreg Steppe

Can you change the Authorization field to test the call with another credential in Explorer? -- Fernando Gois
You can do that by logging in or impersonating the account you want to test and it will give you a new value in the credential/authorization information. -- Chuck Tomasi

How do we get a list of ALL fields for a SN Table? (introspect a table) How do we know what fields for a table are required? How do we get metadata on fields for a SN table? Ex. how do we know what datatype a Field is, ex. How do we know Field_A a string/integar/double/picklist (and it's possible values)? -- Sam Sysum
Good question. I don't know of a way to do that presently. I'll sk our development team. -- Chuck Tomasi

He said it takes your permissions from how you're logged in though? i'll look that up later though. thanks. -- Daniel Nickelson
You're welcome -- Chuck Tomasi

Lol -- Ryan Wattrus
🙂 -- Chuck Tomasi

patch will not create a record if it doesn't exist. put will overwrite or create a new -- Rohitash Laul
Good point! Thanks. -- Chuck Tomasi

Thank you! -- Sarah Mills


Hello, I missed this webinar. is there a way I can get the recorded version? -- sree chalamacharla
It will be made available on the community. -- Chuck Tomasi

hello -- Opeyemi Jegede
Hello -- Kreg Steppe

So the gist = country code --> get key --> display message , right? -- Nhan Tran
Yes. It takes the language I'm currently using to do the lookup of the key. That gives me the right message to pass in to the script variable. -- Chuck Tomasi

What roles are needed to allow this? And could you restrict 'delete' for instance? -- Cameron Wilson
Access is defined based on the credentials used to authenticate with the instance. No specific roles are required. If you don't have access to delete a record via the UI when logged in as firstname.lastname, for example, you won't have any more or less access via the REST API. Security is honored. -- Chuck Tomasi

Hey guys, I found a couple of problems with the PowerShell version, it's in Hi -- John Feist
Sorry, we won't be covering that topic today. -- Chuck Tomasi

What is the difference between Patch verses PUT -- Brenda Zimmerman
We covered that. Thank you. -- Chuck Tomasi

Can you please show how the security parameters are passed from the sample client code to authenticate? -- Rohitash Laul
There is a method available in the javascript class RESTMessageV2(). -- Chuck Tomasi

Forgive me for asking a tangent question but does the new Flow Designer use these OOTB REST APIs when doing e-bonding between multiple instances? -- Joshua Cassity
Not sure. I suggest asking this in the community. -- Chuck Tomasi

sorry... enter too soon -- Rattana Lekskulchai
See below. -- Chuck Tomasi

Not hearing volume. Has this not started? -- Jeanette Tilley
Just started -- Kreg Steppe

Is the REST API Explorer an out of the box feature or is their an additional cost attributed to it? -- Kelli Akinjo
It's out of the box, for free. It comes with the platform and available to all. Good question! -- Chuck Tomasi

what happens if the response doesn't match what you expect? For example you don't get valid JSON? -- Rob Giorgi
That all depends on what you plan to do with the response payload. If you try to parse it with a script, you'll get invalid results. You can check for those and throw an error. The REST API Explorer itself really doesn't care. It makes a request and says "Here's what I got back." -- Chuck Tomasi

Use a script to call the API multiple times. -- Kevin Lamse
Sorry, I don't understand the question. -- Chuck Tomasi

Hi - my company is in the process implementing SN and sunsetting HP Service Manager. I belong on a analytics team and have built out a datamart for HPSM data. Our team wants to put SN data into this mart so we can continue with our current analytics/metrics. Do you have any documentation on how to pull data from SN via c#/vb.net using ODBC or API? Our company does not allow linked servers. -- Soltys John
Hi, we won't be covering that in today's discussion. I invite you to pose your question on the community. -- Chuck Tomasi

What about error control? Need to code for that also. -- Thomas Poeckes
Yes, if you are building the integration to ServiceNow, you'll want to know when something fails. -- Chuck Tomasi

ok thanks. -- Rohitash Laul


Will you highlight the difference between PUT and PATCH - they seem quite similar? -- Brooklin Gore
Good question. I'll see if we can get it in the Q&A section. -- Chuck Tomasi

what version is your IDP? -- Zack Shittu
Sorry, we're not getting in to IDP in this discussion today. -- Chuck Tomasi

Can you configure OAUTH tokens to authenticate? -- richard mauchline
Yes. -- Chuck Tomasi

Sorry, Is Studio avaialble across all levels of ServiceNow ( I am coming from Express to ServiceNow ITSM. -- Jim Basa
Yes -- Kreg Steppe

If a table have 10 records, is it possible to read records from row 3 to 6 using REST API..restricting some rows at a time -- Anju Ravindran
See the above answer to your colleague. -- Chuck Tomasi

Right now, we are writing gs.log statements in the code but is there an OOB table or something where integrations break errors are logged? So we can just send an email notification off of that rather than writing statements in the code. -- keerthana reddy tummala
I invite you to pose that question to the community as it goes beyond the scope of what we are covering today. -- Chuck Tomasi

Is there a walkthrough or a lab available now or during Knowledge where we can set up an integration with an external software? So walking through the whole process -- John Vincent Reyes
I know we'll have labs available on this topic at Knowledge/CreatorCon. I don't know of any online resources at this point. -- Chuck Tomasi

Please send the slide you shared -- Soma Nadarajah
Slides are available on the community. Just search for "TechNow Epsiode List" and you'll find the PPT on the Episode 49 row. -- Chuck Tomasi

Quick training question from non-developer - with limited training budget - what should I get my newbie admins and future developers trained up on? Java Script, Angular, etc. -- Scott Simmons
Javascript! I would consider the ServiceNow Fundamentals class also. -- Kreg Steppe

the get Message syntax which you've shown, is not having sys ID as parameter -- Carmel Franco Kulondai Raj
Correct. it uses the key as the lookup, not the sys_id. Easier to keep track of what messages are being used in your script AND the sys_id is going to be different for different entries in Messages (sys_ui_message) for different language entries. -- Chuck Tomasi

In short, I have no direct access to the REST API Explorer in the server. -- Edgar Punay
It's available under the menu System Web Services> REST> REST API Explorer -- Chuck Tomasi

I have an off-topic question. Would really appreciate it if you answered -- Usama Amir
Thank you. -- Chuck Tomasi

and if true, how can we prevent users from doing API queries? we have many users who are submitting unoptimized queries and we want to shut them down until they agree to change their queries -- Brent Albright
Sorry, I don't understand the question. -- Chuck Tomasi

when doing a GET against incident, will reference fields return the GUID or display value? -- John Feist
You can use either. See the sysparm_display_value URI component. -- Chuck Tomasi

Is there a way to get code samples for Groovy scripting? We are trying to do a Reset with JIRA -- Brian Lancaster
I invite you to pose that question to the community as it goes beyond the scope of what we are covering today. -- Chuck Tomasi

Demo on Oauth in Servicenow -- Rattana Lekskulchai
Thank you. We will consider this for a future topic. -- Chuck Tomasi

Thanks! -- William Coursen


Hi.. is the session started? -- Shiva V
Just about to start now. -- Kreg Steppe

Does REST API return values or names? -- Melissa Hill
You can use either. By default it will return values. There's an option on the form (and gets put in to the URI) to display values, display values, or both. -- Chuck Tomasi

GET Method - can we Use Incident Number to get the Specific record info -- Narasimha Rao
Yes, Specify your sysparm_query as number=INCxxxxxxx -- Chuck Tomasi

do you know if their has been any successful REST integrations from Servicenow to Oracle and vise Versa? -- Priya Yenugunta
I don't know that at present. I encourage you to ask in the community. -- Chuck Tomasi

how does that text expansion work? -- Chris Brown
It is a desktop app. http://bit.ly/2FjvPfO -- Kreg Steppe

We have 7 different integrations to our servicenow platform built by different developers on the team. If the integrations breaks, say, the api changed(for other tool and we are not informed) or attribute that we are pulling is removed from the response then how would i know that the integration breaks -- keerthana reddy tummala
I invite you to pose that question to the community as it goes beyond the scope of what we are covering today. -- Chuck Tomasi

Sorry if this has been addressed I had to step away for a bit, will there be a recording of this made available? -- Ken Laidlaw


when i try to send using an ID other then me with REST Explorer, the login changes to that ID ( similar to i impersonate other ID) then i need to log off and re-login is this expected behaviour ? -- Carmel Franco Kulondai Raj
That was the original behavior. I believe we've taken the credentials off the form (largely because of that bug) in later releases (J? K, for sure) -- Chuck Tomasi

if we have to consume third party webservice , for creating incident ticket , can we make use of rest api explorer ? if yes what is the benefit -- sanjit chanda
The main purpose of the Rest Explorer is for test and development. -- Kreg Steppe

It seems to only go one level deep, it won't return if you try to dot walk beyond the reference field on the root table -- Tim Towstego
That's intentional. Recursive queries are expensive and can lead to very large payloads. It makes more sense to return one set of results, analyze it and determine what, if any child records need to be retrieved. -- Chuck Tomasi

What are the best tips you can give to someone like me who is in an entry-level position ServiceNow Admin certified, with finding a job in the market? -- Usama Amir
Learn all you can. Get a free developer instance at developer.servicenow.com. -- Chuck Tomasi

One way I know to authenticate is to pass secret (auth) code for authentication of the REST APIs. What is auth mechanism used here in ServiceNow to call REST APIs hosted in SN? -- Rohitash Laul
You can use OAuth or Basic Auth to authenticate using REST. -- Chuck Tomasi

Put is used to replace the entire record -- Nyocca Tillman
Thank you. -- Chuck Tomasi

Put overwrites the entire record with blanks, and putting the values you specify. -- Derek Loveless
Thank you. -- Chuck Tomasi

Thank you! -- sam badri


Thanks -- vinay patibandla
You're welcome -- Kreg Steppe

I am currently using the Import Set API to write records to ServiceNow. One drawback is that I must write one record at a time. How can I write batches of records to Import Sets?-- Kevin Leuthold
Good question Kevin. I'll see if we can get it in the Q&A at the end -- Chuck Tomasi

What other OOTB or Third party tools does ServiceNow have coming up in future releases to aid in the advancement or monitoring of Integrations? -- Kelli Akinjo
I don't have any information at this time. If I hear something, I'll let you know. -- Chuck Tomasi

what is the best way to limit what data are exposed to the REST api -- John Feist
ACL or use your scripts to limit the data returned. -- Kreg Steppe

I noticed Rest service role is depricated from jakarta, all itil role inherits the rest service role. In this case how do we handle our api accounts? -- Sindhu Nalluri
All authenticated users have access to the REST APIs. Security is done with ACLs/roles,etc. -- Chuck Tomasi

Ok Thanks, do we have ref doc to create code -- Narasimha Rao
Yes, he'll show you that trick in a bit. -- Chuck Tomasi

Please -- Marianela Solis


Does a comma in the key cause any issues? -- Jonathan Raloff
It's just a string field. Anything is fine. -- Kreg Steppe

i checked that in Istanbul -- Carmel Franco Kulondai Raj
Thanks for the comment. -- Chuck Tomasi

Do you have to do some sort of field mapping first of the record type for instance between Jenkins and change_request_table in Service now first before executing any http verb like a get ? -- sam badri
No, the response payload includes the fields and values. -- Chuck Tomasi

ACL & Data policies in effect also? -- Michael Martone
Yes. -- Chuck Tomasi

With a REST API via script, I have to provide my credentials manually. How can I send a REST API post without having to past my credentials explicitly? -- Christian Lujan
If the endpoint doesn't require authentication, you can skip credentials. If you are using Basic Auth, you can provide them as Base64 encoded in the Authetentication header. -- Chuck Tomasi

Is this the ROLE "web_service_admin" you are referring that should be used to grant users REST API integration access -- Sravi Wadawadigi
No, that role allows one to manage the incoming and outgoing APIs, not grant an account to USE them. -- Chuck Tomasi

Do you have any Demo on -- Rattana Lekskulchai
See below. -- Chuck Tomasi

thanks -- Edgar Punay


I used to remember we could send the request with another credential, other than our own (service account, for example). -- Fernando Gois
That has been removed because it was unreliable. The better approach is to impersonate or login as the service account that user and test the REST API explorer with that user. -- Chuck Tomasi

can the sysparm fields be sorted? -- Troy Baldwin
Not that I know of. -- Kreg Steppe

What version is your idp as I didn't see the average field in my ipd, I am using Jakarta -- Zack Shittu
Average is part of the Aggregate API. Additional APIs are available in later versions. -- Chuck Tomasi

Once I set up the rest, can I save it to use later? -- Jon Porter
The idea is that the REST API Explorer helps you build those. You can get code snippets and the endpoints on the screen, but there is currently no "save" feature. -- Chuck Tomasi

Thanks for the answer about the Import Set API! I have tried sending an array of record updates in the payload, and I've found that only the first record is updated. If you have any other ideas for finding a way to do this, I'd appreciate it. -- Kevin Leuthold
Sorry, I don't understand the question. I invite you to pose your question in our community. -- Chuck Tomasi

I Have joined call after 1st half. are there any other sessions that i can make use of this training -- Santhosh Kumar Bathini
We will be posting the video and Q&A to the community. -- Chuck Tomasi

thanks, guys! -- Christian Alm


Is this "Integration with the REST" session? -- Bojan Arandjelovic
Yes. We are in the Community Tip section of our show, before we move to the Rest talk. -- Kreg Steppe

Sweet! Tks - going to send them to either online or on site Fundamentals Class then -- Scott Simmons


Has Rest API explorer significantly changed between Istanbul and Kingston? -- Michael Keyes
Some notable changes like the credentials, but otherwise unchnaged. If you're familiar with I, you'll be fine in K. -- Chuck Tomasi

If a table have 10 records, can I read row number 3 to 6 using REST API? -- bhuvaneswari gadasala
If you have a way to quewry for that data specifically, otherise I would just get the 10 records and pick them out of the array returned in the response payload -- Chuck Tomasi

Thanks -- Michelle Grace


I've been attempting to rewrite the HelpTheHelpDesk javascript in Powershell. Can REST API used to POST to ECC Queue? Replicating the XML headers and formatting has been a frustration. -- Punahele TANNEHILL
Unfortunately, we don't have time to get in to that depth with this session. I recommend posting that question to the community. -- Chuck Tomasi

Can you recommend a reference guide to learn the Query parameters? -- Mo Figueroa
Try this: https://docs.servicenow.com/bundle/kingston-platform-user-interface/page/use/using-lists/concept/c_EncodedQueryStrings.html -- Chuck Tomasi

Could I have a email to submit more questions? -- Marianela Solis
Email is available at the end of the session. -- Chuck Tomasi

I did not expect a commercial -- Jon Porter
It's short. 🙂 -- Kreg Steppe

What is the performance hit if you have large volumes of data coming out of the CMDB if you expose a Rest API -- Michelle Grace
All tables have REST APIs by default, so we're not exposing anything that's not already there. As for performance, it's the same as if you export an Excel. There's going to be some CPU hit, but won't crush the system. I encourage queries rather than entire dumps of data. If you have to do large exports, do some load testing to understand the impact (frequency, size, etc.) before moving to production. -- Chuck Tomasi

If I deliver a REST api endpoint to a customer for data query, what roles do I need to provide, or ACLs do I need to contend with? -- Mark Beaver
Standard roles and ACLs apply to the credentials you provide. Nothing special about doing REST requests. -- Chuck Tomasi

Who is Earl? -- Ryan Wattrus
He lives in URL, USA -- Kreg Steppe

If i'm understanding correctly, all ITIL users have access to make REST API calls against our instance. Is that true? -- Brent Albright
In short, all authenticated users have access to the REST APIs. -- Chuck Tomasi

Thank you. -- Punahele TANNEHILL


Can you use a REST API Call to run a collection from a data source? -- Christopher Moore
Not sure I understand the question. -- Chuck Tomasi

Will you be recording this session? -- Jim Stifflear
Yes -- Kreg Steppe

will the version default to the latest (V2) if you don't specify that as part of your URI? -- Chance Robinson
Yes it will -- Kreg Steppe

can you use the rest API explorer against external targets? troubleshooting connections to third party tools? -- Ben Rollins
The Explorer is designed to test and develop your own API in ServiceNow. There are desktop tools for testing any API end point -- Kreg Steppe

I'm still new to ServiceNow...Is this different than Scripted REST APIs? -- Daniel Chang
Yes. The REST API Explorer is a means to help third party apps integrate quickly to ServiceNow using any REST endpoint the instance has to offer. Those endpoinds included scripted REST APIs along with table APIs, import set APIs, and others. -- Chuck Tomasi

you mentioned the user has the same security using the REST api as they would if they were logged in. But if our instance is SSO I have to give the user basic auth. Unless I set up Oauth. I've never used Oauth or set it up in SN. Can you demo Oauth use and setup? -- Patrick Doran
Thak you. We will consider it. -- Chuck Tomasi

Thanks -- Narasimha Rao
You're welcome -- Chuck Tomasi

What's the difference between: Retrieve records from a table (GET) VS Retrieve a record (GET)? Which one is better? Why? -- GAUTAM ADHIKARI
One gets a single record, the other returns an array of records. -- Chuck Tomasi

thanks -- Marianela Solis

Do we get login events(login or login.failed)fire when a REST account accesses the instance?

Chuck Tomasi
ServiceNow Employee
ServiceNow Employee

Yes. I just tried it with a cURL command with invalid credentials and it logged login.failed as well as an error message in the system log.