AnsweredAssumed Answered

API Script no longer works after API update

Question asked by Erich Lengfeld on Feb 9, 2017
Latest reply on Feb 9, 2017 by Jeff Leggett

After recent API update my script no longer works see below:



$user = "q_user"
$pass = "q_Pass"
$authInfo = [System.Convert]::ToBase64String([System.Text.Encoding]::UTF8.GetBytes("$user`:$pass"))
$headers = @{"X-Requested-With"="powershell";"Authorization"="Basic $authInfo"}
#API call to get Report ID
Invoke-RestMethod -Uri "" -headers $headers -Method post -OutFile C:\xxxxx
[xml]$XML = Get-Content C:\xxxx
#Pull report of servers in Qualys 
Invoke-RestMethod -Uri "$NewestReport&echo_request=1" -headers $headers -Method get -OutFile C:\xxx



Invoke-RestMethod :
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 C:\xxxxxx
+ Invoke-RestMethod -Uri " ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (System.Net.HttpWebRequest:HttpWebRequest) [Invoke-RestMethod], WebException
+ FullyQualifiedErrorId : WebCmdletWebResponseException,Microsoft.PowerShell.Commands.InvokeRestMethodCommand



When I use the account to log into the site directly it works so it is not invalid creds.