401 Unauthorized error from Powershell to ServiceNow
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-23-2020 07:31 AM
Hello Experts,
Don't know whether this is a right question asking here. But I need your assistance on this.
There is a powershell script which connects SN to customer_contact table to fetch the record via token concept. I don't know why I am getting below error. I've tried changing the token but still issue persists. Can anybody help me to sort this out.
VERBOSE: Getting customer contacts from SNOW ContactUri: https://{instance_name}.service-now.com/api/now/table/customer_contact?sysparm_query=u_portalenabled_1=yes&sysparm_fields=name,email,u_portalenabled_1,sys_id,active,user_name
VERBOSE: GET https://{instance_name}.service-now.com/api/now/table/customer_contact?sysparm_query=u_portalenabled_1=yes&sysparm_fields=name,email,u_portalenabled_1,sys_id,active,user_name with 0-byte payload
>> TerminatingError(Invoke-WebRequest): "The remote server returned an error: (401) Unauthorized."
>> TerminatingError(LogEvent): "The running command stopped because the preference variable "ErrorActionPreference" or common parameter is set to Stop: Error retreiving data from the SNOW web service: The remote server returned an error: (401) Unauthorized."
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-24-2020 05:32 AM
Can anybody assist.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-24-2020 05:39 AM
Hi Vikram,
What authentication type you are using for REST Service (Basic or OAuth)? is the user profile used to authenticate REST call has "snc_platform_rest_api_access" role?
Thanks,
Ali
Thank you,
Ali
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-24-2020 06:26 AM
user has admin role
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-24-2020 05:47 AM
Hi Vikram,
Usually error 401 means incorrect username and password
Is that user having valid Table level READ ACL to access the table data
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader