# token error using API "401 could not parse JWT"

**URL:** <https://community.dynatrace.com/t/token-error-using-api-401-could-not-parse-jwt/55507>\
**Category:** Dynatrace API\
**Tags:** dynatrace-api, tokens\
**Created:** [April 8, 2026, 7:39pm UTC](https://community.dynatrace.com/t/token-error-using-api-401-could-not-parse-jwt/55507 "2026-04-08T19:39:04Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![dcbarry](https://avatars.discourse-cdn.com/v4/letter/d/c0e974/32.png) [@dcbarry](https://community.dynatrace.com/u/dcbarry)\
**Post date:** [April 8, 2026, 7:39pm UTC](https://community.dynatrace.com/t/token-error-using-api-401-could-not-parse-jwt/55507/1 "2026-04-08T19:39:04Z")

</div>

Performing what should be a simple DQL query via API, I get a 401 - Could not parse JWT".&nbsp; &nbsp;I understand this to be an token issue.

The confusion is that the token is fully usable in a different api call.&nbsp; (I intentionally over-provisioned the token giving ALL 38 scopes)

The failing query works in the swagger test -- unless I explicitly provide a token instead of my login.

I do recognize there is a difference (which I don’t still fully understand) in the “live” vs “apps” url,&nbsp; SHould I be using a different form of token?&nbsp; If so, can I get guided to it? THank you in advance.

**THIS CODE WORKS:**

```java
$ApiToken = "dt0c01.REDACTED"
$Uri = "https://{environmentid}.apps.dynatrace.com/platform/storage/query/v1/query:execute?enrich=metric-metadata"

$Body = @"
{
  "defaultSamplingRatio": 1,
  "defaultScanLimitGbytes": 10,
  "defaultTimeframeEnd": "2026-04-08T00:00:00.000Z",
  ... TRIMMED, not directly relevant ....
}
"@

$DQLQuery = Invoke-RestMethod -Uri $MetaUrl -Headers $Headers -Method POST -Body $Body
$DQLQuery | ConvertTo-Json -Depth 99 | Out-File -FilePath "C:\temp\DQLQuery.json" -Encoding UTF8
Write-Host "DQLQuery response saved to C:\temp\DQLQuery.json"

```

---

<div class="post-metadata">

**Author:** ![RohitBisht](https://dub1.discourse-cdn.com/dynatrace/user_avatar/community.dynatrace.com/rohitbisht/32/38577_2.png) [@RohitBisht](https://community.dynatrace.com/u/RohitBisht)\
**Post date:** [April 9, 2026, 5:11am UTC](https://community.dynatrace.com/t/token-error-using-api-401-could-not-parse-jwt/55507/2 "2026-04-09T05:11:17Z")

</div>

Hi,

While we have classic API’s that just need API token to access [\*.live.com], GRAIL API’s are part of the Gen3 Platform(\*.apps.\*) in Dynatrace and need OAuth2.0 to access them.  
You should try creating a token via below method and see if it works.  
[Access platform APIs from outside | Dynatrace Developer](https://developer.dynatrace.com/develop/guides/access-platform-apis-from-outside/)

Another way is to get a platform token for programmatic access:

> **[Platform tokens](https://docs.dynatrace.com/docs/manage/identity-access-management/access-tokens-and-oauth-clients/platform-tokens)**
>
> Create personalised platform tokens to access Dynatrace services via the API in your user context.
