25 Mar 2026
04:08 PM
- last edited on
26 Mar 2026
07:55 AM
by
MaciejNeumann
I'm having trouble determining how to retrieve the results of an already defined DQL query in a notebook. I've reviewed docs everywhere, but can seem to get it functional. My token has full read rights everywhere, and is the owner of the notebook (my personal api). The UUIDs are triple confirmed as valid. (Short and long form).
I keep getting 404 (not found) error, although the docs imply this is the way. ("api/v1/documents").
My code looks like this: (Fake tenant IDs)
I am aware I'm supposed to be able to invoke DQL from my API call directly, this is not a desirable solution. Wish to use what is already in the notebook.
$DynaHost = "https://{environmentid}.live.dynatrace.com"
#Note: I've tried both the extended and short forms of the ID
#$NotebookId = "27268a8e-4667-4373-beda-dddb427f0ead#9b9fde91-f574-47bd-b89a-7c4584d1e02d"
$NotebookId = "27268a8e-4667-4373-beda-dddb427f0ead"
$ApiUrl = "$DynaHost/api/v1/documents/$NotebookId"
try {
$notebookContent = Invoke-RestMethod -Uri $ApiUrl -Headers $Headers -Method Get
Write-Host "Content for Notebook $NotebookId"
$notebookContent | ConvertTo-Json -Depth 99 | Out-File -FilePath "C:\temp\$NotebookId.json"
} catch {
Write-Host 'Error retrieving notebook content: $_.Exception.Message'
}
25 Mar 2026 04:55 PM - edited 25 Mar 2026 05:10 PM
Hello @dcbarry
Let me see if I can help you with this one...
I was checking your code and maybe miss the "platform" in the endpoint.
$DynaHost = "https://{environmentid}.live.dynatrace.com"
$NotebookId = "27268a8e-4667-4373-beda-dddb427f0ead"
# Metadata
$MetaUrl = "$DynaHost/platform/document/v1/documents/$NotebookId"
# Content download
$ContentUrl = "$DynaHost/platform/document/v1/documents/$NotebookId/content"
try {
$notebookMeta = Invoke-RestMethod -Uri $MetaUrl -Headers $Headers -Method Get
$notebookMeta | ConvertTo-Json -Depth 99 | Out-File "C:\temp\$NotebookId-meta.json"
Invoke-WebRequest -Uri $ContentUrl -Headers $Headers -Method Get -OutFile "C:\temp\$NotebookId-content.bin"
Write-Host "Notebook metadata retrieved successfully."
Write-Host "Notebook content downloaded to C:\temp\$NotebookId-content.bin"
}
catch {
Write-Host ("Error retrieving notebook: " + $_.Exception.Message)
if ($_.ErrorDetails.Message) {
Write-Host $_.ErrorDetails.Message
}
}And in my POV there is not a supported “give me the already-rendered result set from this notebook section” endpoint, unfortunately. The supported path is to read the notebook content, extract the DQL from the section, and execute that DQL through the Grail Query API.
I hope this helps you 😀
25 Mar 2026 05:26 PM
Thanks for responding!
HHmm.. that gives me a 403 forbidden, error. However, I noted I accidentally deleted the build of headers in my original code. Including:
25 Mar 2026 05:29 PM
My pleasure, happy to help. Keep us updated this topic is really interesting, actually
08 Apr 2026 08:55 PM
hey, just thought you'd like to know, i decided to take the other approach, and directly do a DQL query as suggested. However, now Im having token troubles. LOL. so, i reposted with examples.
09 Apr 2026 08:51 AM
Heyy! Nice to know, could you gently attach the link to this new post, please? If this helped you, and if you think it's fair, Kudos helps me 😁
Featured Posts