Get sys_id from current user using REST API Services

markwinap
Giga Contributor

Hi, Im using Authorization code grant flow (OAuth 2) to authenticate users and get them access to Service Now RESTful APIs. My question is, how do i get the user sys_id (similar to  var currentUser = gs.getUser(); gs.info(currentUser.getID());) using the available RESTful APIs.

 

My current workaround is,POST to the incident table and get the sys_id from opened_by key

1 ACCEPTED SOLUTION

If it is a scripted rest api, you can easily assign value to an attribute.

 

For example body.USER = gs.getUserID();


Please mark this response as correct or helpful if it assisted you with your question.

View solution in original post

6 REPLIES 6

SanjivMeher
Kilo Patron
Kilo Patron

You can use gs.getUserID() to get the sys id of the current user


Please mark this response as correct or helpful if it assisted you with your question.

sanjivmeher, thanks for your response however im looking into REST API services only for a server-less application

Can you elaborate more? 

You are sending a rest api to ServiceNow? And you want to send response back with the sysid of the user using which you are sending the rest api?


Please mark this response as correct or helpful if it assisted you with your question.

That is correct