The CreatorCon Call for Content is officially open! Get started here.

Get the user sys_id by usrname in REST API?

SacSen
Kilo Explorer

Hi,

I am trying to get the user's sys_id by using user's username. But I can find a proper way of implementing on API docs or in Google. I am using REST api to consume SNOW api. Guidance would highly appreciate. 

2 REPLIES 2

DScroggins
Kilo Sage

Hello,

 

If you are querying the user table you can use the below (update with your values) to retrieve the users sys id using their username and a GET request:

https://<INSTNACE>.service-now.com/api/now/table/sys_user?sysparm_query%3Duser_name=<USERNAME>&sysparm_fields=sys_id&sysparm_limit=1

 

The response will look like so:

{
  "result": [
    {
      "sys_id": "63991c152be65a00467e06d119da7777"
    }
  ]
}

 

Hope this helps.

 

--David

 

kenneth_atb
Tera Contributor

The way that actually worked for me was:

https://<instance>.service-now.com/api/now/table/sys_user?sysparm_query=name%3D<name>&sysparm_fields=sys_id&sysparm_limit=1

{
    "result": [
        {
            "sys_id": "3d0a93de93f63d50d5dab8786cba10c7"
        }
    ]
}

Hope this works for anyone with this question.

Regards.