Your credentials could not be authenticated: "Credentials are missing.". You will not be permitted..

mh2022
Tera Contributor

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!

 

 

 

 

6 REPLIES 6

jaheerhattiwale
Mega Sage

@mh2022 Send the credentials as basic auth. It should work.

I'm using the "default" PowerShell script ServiceNow provides which does default to "basic" so I know that part is good.

reshmapatil
Tera Guru

Hi @mh2022 ,

 

  1. Open User[sys_user] table in ServiceNow.reshmapatil_2-1671266224778.png
  2. Create a new user and mark 'Web service access only' and 'Internal Integration User'reshmapatil_3-1671266418393.png

     

  3. Use this user for authorization.
  4. 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**

I did mark those boxes and still have the same error message.