08 Apr 2026
08:39 PM
- last edited on
09 Apr 2026
01:04 PM
by
MaciejNeumann
Performing what should be a simple DQL query via API, I get a 401 - Could not parse JWT". I understand this to be an token issue.
The confusion is that the token is fully usable in a different api call. (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, SHould I be using a different form of token? If so, can I get guided to it? THank you in advance.
THIS CODE WORKS:
$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"
09 Apr 2026 06:11 AM
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
Another way is to get a platform token for programmatic access:
https://docs.dynatrace.com/docs/shortlink/platform-tokens
Featured Posts