Getting full node list from data-rooms (subfolders with children)
Hello!
I'm trying to get whole subnode list for data room. and I can't find a solution...
I.E I have one data room with ~2500 folders and each folder also contains some children... so how I can get this info using the API?
-
The endpoint you need is /v4/nodes/search
You can only load the metadata for the nodes in tranches of 500 pieces. So you have to get 500 nodes until you get less than or equal to 500 at some point and in the next step 0.
Of course you have to include a variable that counts from which number should be picked up in the next step and a variable that accepts all nodes and is incremented with each step.Here is an example implemented in PowerShell:
$allElements = $null
$offset = 0
do {
$parameter = @{
"depth_level" = "-1"
"search_string" = "*"
#"parent_id" = "25" #search only under this node
"limit" = "500"
"offset" = $offset
#"filter" = "type:eq:folder:room" # search only for folders & rooms
}
#do the search
$AccountUrl = $APIUrl + "/v4/nodes/search"
$Response = Invoke-WebRequest -URI $AccountUrl -Method Get -ContentType "application/json" -Headers @{Authorization = ("Bearer {0}" -f $Token) } -Body $parameter
$content = ConvertFrom-Json $Response.content
$inhalt = $content.items
$offset = $offset + 500
$allElements = $allElements + $inhalt
}
while ($inhalt -ne $null)
Write-Host $allElements.count " nodes were found."
Bitte melden Sie sich an, um einen Kommentar zu hinterlassen.
Kommentare
2 Kommentare