Your credentials could not be authenticated: "Credentials are missing.". You will not be permitted..
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-16-2022 01:32 PM
Hi,
Disclaimer: I'm not a ServiceNow expert as I am a developer on the "client side" so forgive me in advance for asking this. (Other people I work with are ServiceNow experts). I use the Rest API Explorer fine to run a simple query to get all the incidents:
https://devXXXXX.service-now.com/api/now/table/incident?sysparm_limit=1
This works fine in-browser (as default admin user). when I copy the PowerShell script and try to run it from my PC I get the following message (which I'm certain I have the correct credentials aside from knowing the script is correct since I coped it from the REST API explorer page):
Invoke-RestMethod :
Access Denied
Access Denied (authentication_failed)
Your credentials could not be authenticated: "Credentials are missing.". You will not be permitted access until your credentials can be verified.
This is typically caused by an incorrect username and/or password, but could also be caused by network problems.
For assistance, contact your network support team.
At line:24 char:13
+ $response = Invoke-RestMethod -Headers $headers -Method $method -Uri ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (System.Net.HttpWebRequest:HttpWebRequest) [Invoke-RestMethod], WebException
+ FullyQualifiedErrorId : WebCmdletWebResponseException,Microsoft.PowerShell.Commands.InvokeRestMethodCommand
I have run many PowerShell scripts in the past but this is a new environment so I'm not sure what the steps are within the ServiceNow application to allow Rest API queries? (I browsed the many forums articles and the closest ones I could find mentioned endpoints and in/out bound API setup none of which I know anything about or how to use. Any kind of detailed response would be greatly appreciated). Thanks again in advance!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-19-2022 07:01 AM
I had a suspicion today since my previous employer worked perfectly with the default script. I disconnected from my company VPN and the default script worked perfectly! It appears my laptop is going through a company proxy server when connected through the VPN so I at least know the issue now.
Any chance someone knows how to properly tunnel/auth through a company proxy server? (I see some PowerShell options regarding proxies and I also have seen some possible options in the header of the API call itself)