# Auth Error on Invoke-RestMethod

**URL:** <https://community.dynatrace.com/t/auth-error-on-invoke-restmethod/32620>\
**Category:** Extensions\
**Tags:** extensions, dynatrace-api\
**Created:** [September 8, 2021, 7:13am UTC](https://community.dynatrace.com/t/auth-error-on-invoke-restmethod/32620 "2021-09-08T07:13:36Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![J1ir](https://avatars.discourse-cdn.com/v4/letter/j/439d5e/32.png) [@J1ir](https://community.dynatrace.com/u/J1ir)\
**Post date:** [September 8, 2021, 7:13am UTC](https://community.dynatrace.com/t/auth-error-on-invoke-restmethod/32620/1 "2021-09-08T07:13:36Z")

</div>

Hi All

I’m following the Extensions 2 documentation to get&nbsp;schemas provided through the&nbsp;Extension 2.0.

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

$Token&nbsp;=&nbsp;“xxxx”$uri&nbsp;=&nbsp;“[env].live.dynatrace.com/api/v2/extensions/schemas”$headers&nbsp;=&nbsp;@{&nbsp;&nbsp;&nbsp;&nbsp;“Authorization”&nbsp;=&nbsp;“Api-Token&nbsp;$Token”&nbsp;&nbsp;&nbsp;&nbsp;‘Content-Type’&nbsp;=&nbsp;‘application/json’}Invoke-RestMethod&nbsp;-Uri&nbsp;$uri&nbsp;-Method&nbsp;Get&nbsp;-Headers&nbsp;$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

---

<div class="post-metadata">

**Author:** ![ChadTurner](https://dub1.discourse-cdn.com/dynatrace/user_avatar/community.dynatrace.com/chadturner/32/161_2.png) [@ChadTurner](https://community.dynatrace.com/u/ChadTurner)\
**Post date:** [September 22, 2021, 5:43pm UTC](https://community.dynatrace.com/t/auth-error-on-invoke-restmethod/32620/2 "2021-09-22T17:43:21Z")

</div>

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&nbsp;=&nbsp;@{&nbsp;&nbsp;&nbsp;&nbsp;“Api-Token”&nbsp;=&nbsp;“$Token”

---

<div class="post-metadata">

**Author:** ![Chris\_Fors](https://avatars.discourse-cdn.com/v4/letter/c/c37758/32.png) [@Chris\_Fors](https://community.dynatrace.com/u/Chris_Fors)\
**Post date:** [November 9, 2022, 12:51pm UTC](https://community.dynatrace.com/t/auth-error-on-invoke-restmethod/32620/3 "2022-11-09T12:51:40Z")

</div>

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
