ClientID appears to be required when making CWA REST calls.
Rbartram opened this issue · 2 comments
Rbartram commented
Recently, I've started getting the following error when trying to use AutomateAPI:
Get-AutomateAPIGeneric : Failed to perform Invoke-RestMethod to Automate API with error The remote server returned an error: (401) Unauthorized..Exception.Message
At C:\Users\rbartram\Dropbox\Powershell Scripts\Modules\AutomateAPI-master\Public\Get-AutomateComputer.ps1:430 char:20
Using Postman, I found that "clientid" is needed in the headers.
I've gotten around this by inserting a clientid statically as follows, but this can't be the best way to address this...
##Rob 2020-12-16 - Switching to $headers to include clientid
$headers = @{
'clientid' = 'xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx'
'Authorization' = $script:CWAToken.Authorization
}
##/Rob 2020-12-16
try {
##Rob 2020-12-16 Switching to $headers to include clientid
#$return = Invoke-RestMethod -Uri $URLNew -Headers $script:CWAToken -ContentType "application/json" -Body $Body
$return = Invoke-RestMethod -Uri $URLNew -Headers $headers -ContentType "application/json" -Body $Body
#/Rob 2020-12-16
}
DarrenWhite99 commented
Did you check out Release 1,1.4 (#53)?
This should be resolved by the current master branch version.
Rbartram commented
Thank you very much Darren. I'll grab the branch version.