- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-02-2025 03:02 AM
Outbound Rest Message (which uses OAuthToken) not working in the Run script Workflow
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-13-2025 09:30 AM
It finally worked when the rest call was executed via Business Rule,
I created an asynchronous BR to implement it.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-02-2025 05:17 AM
did you check the workflow run script is working with which user's session?
Seems the user who submitted the request is not able to get the OAuth token
check this link
Non-admin users cannot retrieve OAuth token from OAuth Credentials table to make outbound REST call
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-02-2025 09:55 AM
I tried creating ACLs still it's not working it's still giving error code 401 when run from workflow and on the other hand, it's working fine in the background script
Both are currently run in my user's session and I am an Admin.
It's still unclear.
Thank you in advance for all your help !!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-02-2025 10:15 AM
Hi Aishwarya ,
Check if you have setup Authentication Profile correctly or not . It might be one of the possible causes.
and also Background scripts run in the context of an admin user, while workflow scripts may run under a different user or system context. This can affect permissions, token generation, and access to resources.
var r = new sn_ws.RESTMessageV2('<Rest Message>', '<method name>');
r.setAuthenticationProfile('oauth2', '<OAuth_Profile_Name>');
r.setStringParameterNoEscape('userId', '<userId>');
var response = r.execute();
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-03-2025 09:13 AM
Hi @rajeev17 ,
I tried doing this, this is not working 😞
Is there any other way ?
Thank you in advance !