J1ir
September 8, 2021, 7:13am
1
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
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”
A working example of the above (works in Powershell) :
$Token = ‘xxxxxxx’
$Params = @{ “URI” = ‘https://[ENV].live.dynatrace.com/api/config/v1/extensions/’
“Method” = ‘GET’
“Headers” = @{
“Content-Type” = ‘application/json; charset=utf-8’
“Authorization” = ‘Api-Token’ + ’ ’ + $Token
}
}
Invoke-RestMethod @Params