Impersonate on a PUT query to Rest API

Mathieu Cote
Kilo Explorer

Hello,

I'm using the rest api from a 3rd party application to get and send data to servicenow. I was wondering if it's possible to impersonate someone while using a query PUT https://<instance>.service-now.com/api/now/table/incident/<sys_id> ?

My goal is to add a comment to an existing incident as someone else. My http request already contains an Authorization header using credentials of an admin account.

2 REPLIES 2

erik_brostrom
Mega Guru

I don't think you can do this directly with the OOB table API, but you could create a scripted REST API that includes the following collected by a parameter:

new GlideImpersonate().impersonate(user);

Another community post that may be of interest:

https://community.servicenow.com/community?id=community_question&sys_id=ec5fd1a9dbf21f40200f0b55ca961938

Thanks Erik, I did not know about the Scripted REST services I could create and call in servicenow.

I found an existing one in there called "impersonate" and I think I successfully called it. I will look for another service to do what I need after the impersonate or I will create a new one.

I don't know yet if the impersonate will still be enabled on further Scripted REST service calls, I might end up creating one that does the impersonate + my changes + unimpersonate.