get the user who accessed the rest API?

Kiddy1
Tera Contributor

hello

 

i have created a scripted rest api

 

https://xxxxxxxxxxxxxxxxxxxxxx.service-now.com/api/catsf/createrequest

i have 3 users from 3 different domains accessing this path

can i get the user who has accessed this path when it is called, In scripted api so that i can check the domain of that user and allow him to create request in that domain, if he is member of that domain??

 

thanks in advance

1 ACCEPTED SOLUTION

ARG645
Tera Guru

If you want to get the user information in the scripted rest API. You can log them in the script part of the Resource. Once you get the user information , you can do gliderecord on sys_user table or use gs.getUser().getDomainID(); to get the Domain information and proceed further. 

find_real_file.png

 

 

View solution in original post

2 REPLIES 2

JJ1
Kilo Guru

Does your scripted web service use authentication ? we use gs.getUserID() to get the user ID as we have multiple servicenow service accounts using the same scripted web service .

ARG645
Tera Guru

If you want to get the user information in the scripted rest API. You can log them in the script part of the Resource. Once you get the user information , you can do gliderecord on sys_user table or use gs.getUser().getDomainID(); to get the Domain information and proceed further. 

find_real_file.png