I’m trying to add some new features to my obsidian package and I’m wanting to get the full content tree via the Management API. I’ve looked at the swagger docs but no endpoint is jumping out at as “the one”.
Has anyone managed to do this at all and if so, do you have any pointers.
I’m wanting to pull back all the content so that I can then get the UUID of a selected node.
After a bit of trial and lots of error, I’ve managed to pull back the content tree via the Management API. You need to have an authroisaton token before any of this works but once you have that you make a couple of calls and some recursive fetching.
Could maybe be done better but it works for what I need it
async function fetchAllContentNodes(
websiteUrl: string,
token: string,
parentId: string | null = null,
depth: number = 0
): Promise<any[]> {
const endpoint = parentId
? `${websiteUrl}/umbraco/management/api/v1/tree/document/children?parentId=${parentId}`
: `${websiteUrl}/umbraco/management/api/v1/tree/document/root?skip=0&take=100&foldersOnly=false`;
const response = await requestUrl({
url: endpoint,
method: 'GET',
headers: { 'Authorization': `Bearer ${token}` },
});
const items = (response.json as any).items || [];
let allNodes: any[] = [];
for (const item of items) {
// Add current node with depth for indentation
allNodes.push({ ...item, depth });
// Recursively fetch children
const children = await fetchAllContentNodes(websiteUrl, token, item.id, depth + 1);
allNodes = allNodes.concat(children);
}
return allNodes;
}
Now, this returns all the content but I then need to get the name of the nodes via