Search code examples
javarestservicenowservicenow-rest-api

Get the user sys_id using REST API in ServiceNow?


I am trying to get the user sys_id by username using the SNOW REST API. But I couldn't find a way of doing it in the SNOW API doc.

Is it impossible to do so or any other alternative way of doing it?


Solution

  • Yes, this is a simple GET call. sys_id isn't returned on the default fields but will be returned if you explicitly request it:

    https://[your instance].service-now.com/api/now/table/sys_user?sysparm_query=user_name%3D[your username]&sysparm_fields=sys_id&sysparm_limit=1
    

    The REST api explorer is very handy for building and testing queries like this. You can find it by searching the navigator.