REST API to get the logged in user details

sahilkhanna
Tera Expert

I'm new to Service Now and am exploring REST APIs.

 

I have created a user named "Ajay". I have got the access_token of this user. I am getting the details of this user using the below request.

curl --location 'https://dev191.service-now.com/api/now/table/sys_user' \
--header 'Accept: application/json' \
--header 'Authorization: Bearer Vmxn6CYIC...............OohTqA'

The request returns the list of all users. However, I want the request to return only the user identified in the access_token.

2 ACCEPTED SOLUTIONS

JenniferRah
Mega Sage

Maybe what you are looking for is this?

GET instance.service-now.com/api/now/ui/user/current_user

View solution in original post

Juhi Poddar
Kilo Patron

Hello @sahilkhanna 

Set the endpoint to "https://dev191.service-now.com/api/now/ui/user/current_user"

 

"If you found my answer helpful, please like and mark it as an "accepted solution". It helps others find the solution more easily and supports the community!"

 

Thank You
Juhi Poddar

View solution in original post

7 REPLIES 7

Juhi Poddar
Kilo Patron

Hello @sahilkhanna 

Set the endpoint to "https://dev191.service-now.com/api/now/ui/user/current_user"

 

"If you found my answer helpful, please like and mark it as an "accepted solution". It helps others find the solution more easily and supports the community!"

 

Thank You
Juhi Poddar

Hello @sahilkhanna 

Thank you for marking my response helpful. 

As per the new community policy, you can accept multiple answers as an accepted solution.

Can you please mark my solution as well as an accepted solution, it will help future readers to locate the solution easily.

 

Thank You

Juhi Poddar

sahilkhanna
Tera Expert

Apart from the accepted answers, below is another way to get the logged-in user's information.

https://dev191.service-now.com/api/now/table/sys_user?sysparm_query=sys_id=javascript:gs.getUserID()