cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Auth Error on Invoke-RestMethod

J1ir
Newcomer

Hi All

 

I'm following the Extensions 2 documentation to get schemas provided through the Extension 2.0. 

 

I'm using Powershell's invoke-restmethod. This is my current code:

 

$Token = "xxxx"
$uri = "[env].live.dynatrace.com/api/v2/extensions/schemas"
$headers = @{
    "Authorization" = "Api-Token $Token"
    'Content-Type' = 'application/json'
}
Invoke-RestMethod -Uri $uri -Method Get -Headers $headers 

 

Having tried a few iterations, I consistently get:

 

Invoke-RestMethod : {"error":{"code":401,"message":"Missing authorization parameter."}}

 

I'm using a token generated from dynatrace. 

 

Any help on where I'm going wrong would be appreciated.

 

 

Cheers

1 REPLY 1

ChadTurner
DynaMight Guru
DynaMight Guru

Were you able to get this sorted out? If the Token has the correct permissions - which im assuming it does since the error does not reference a lack of permissions, rather the authorization parameter. It looks like you code might not be correct. Try this:

 

$headers = @{
    "Api-Token" = "$Token"
 
 
-Chad