Skip to main content

 

Hi Everyone

I’m new to the API.  guess im doing something wrong related to authentication. I can query through postman without any issues using my key but no luck with the below code :

 

Here is what Im tryin to run through PS but I always get an “(401) Unauthorized.” error message


$headers=@{
Authorization="MyAccessKeyStringhere";
Content='application/json'
}


$uri = "https://console.automox.com/api/reports/prepatch"


$result = Invoke-restmethod -Uri $uri -Headers $headers -method get

$result  | select -expandproperty profile |select name

 

 

Thanks a lot for any help. 

Diego

 

Hello Diego,

You will need to specify your orgID in the URI. For example:

$orgid='<your_org_id>'

$apiKey = '<your_api_key>'

$headers=@{

Authorization = "Bearer $apiKey"

Content='application/json'

}

$url = "https://console.automox.com/api/reports/prepatch?o=$orgid"

$response = (Invoke-WebRequest -Method Get -Uri $url -Headers $headers).Content | ConvertFrom-Json

Write-Output $response

Try that out.

Kind regards,


And adding to ElmerP’s code here, I was able to break it down to the device info, which might be what you were looking for with the Name property.
 

$orgid='<your_org_id>'

$apiKey = '<your_api_key'

$headers=@{

Authorization = "Bearer $apiKey"

Content='application/json'

}

$url = "https://console.automox.com/api/reports/prepatch?o=$orgid"



$response = (Invoke-WebRequest -Method Get -Uri $url -Headers $headers).Content | ConvertFrom-Json

Write-Output $response.prepatch.devices

 


 

Thank you so much to both !!!

 


Reply