1

I am looking into getting Parent Folder data for subfolders in BIM 360 using Nodejs and Forge

I see the method in Forge GET https://developer.api.autodesk.com/data/v1/projects/:project_id/folders/:folder_id/parent

How to implement this code similar to the GetItemDetails:

async function getItemInfo(client, projectId, itemId) {
 var itemdetails = await client.getItemDetails(projectId, itemId);
 var temp = itemdetails.folder;
 return temp;
 }

1 Answers1

0

It's quite straightforward.

Find the folder where the item you want is via calling https://forge.autodesk.com/en/docs/data/v2/reference/http/projects-project_id-items-item_id-parent-GET/. Here is the code snippet of using Forge nodejs client SDK:

const { FoldersApi, ItemsApi } = require('forge-apis');
const items = new ItemsApi();

const itemParentFolderContents = await items.getItemParentFolder(projectId, itemId, {}, oauthClient, credentials);
 
const itemParentFolderData = itemParentFolderContents.body.data; 

Then you can call the parent folder endpoint you mentioned to get the folder parent of the folder where the item is located at. https://forge.autodesk.com/en/docs/data/v2/reference/http/projects-project_id-folders-folder_id-parent-GET/ Here is the code snippet of using Forge nodejs client SDK:

const folders = new FoldersApi();
const parentFolderContents = await folders.getFolderParent(projectId, itemParentFolderData.id, {}, oauthClient, credentials);
 
const parentFolderData = parentFolderContents.body.data; 
Eason Kang
  • 6,155
  • 1
  • 7
  • 24