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-16-2022 09:36 PM
@mh2022 Send the credentials as basic auth. It should work.
ServiceNow Community Rising Star, Class of 2023
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-19-2022 06:58 AM
I'm using the "default" PowerShell script ServiceNow provides which does default to "basic" so I know that part is good.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-17-2022 12:42 AM - edited 12-17-2022 12:46 AM
Hi @mh2022 ,
- Open User[sys_user] table in ServiceNow.
- Create a new user and mark 'Web service access only' and 'Internal Integration User'
- Use this user for authorization.
- Select Authorization type as Basic Auth in PowerShell and pass username and password of ServiceNow user.
Note: We also have an option in ServiceNow to execute the PowerShell script.
Regards,
Reshma
**Please mark my answer correct or helpful based on the impact**
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-19-2022 06:58 AM
I did mark those boxes and still have the same error message.