Search code examples
.netpostautodesk-forgecreate-directory

How to create a folder on BIM 360 though .NET


I am currently trying to create a folder inside the Plans Top Folder with the name "NET folder". Using my method, the program crashes with the output:

Failed to load resource: the server responded with a status of 500 (Internal Server Error)

The code below is what I am currently using:

CreateFolderDataRelationshipsParentData createFolderRelationshipsParentData = new CreateFolderDataRelationshipsParentData(
    "folders",
    parentFolderId);
CreateFolderDataRelationshipsParent createFolderDataRelationshipsParent = new CreateFolderDataRelationshipsParent(createFolderRelationshipsParentData);
CreateFolderDataRelationships createFolderDataFolderRelationships = new CreateFolderDataRelationships(createFolderDataRelationshipsParent);
BaseAttributesExtensionObjectWithoutSchemaLink baseAttribute = new BaseAttributesExtensionObjectWithoutSchemaLink(
    "folders:autodesk.bim360:Folder",
    "1.0",
    folderInfo.Value.attributes.extension.data);
CreateFolderDataAttributes createFolderDataAttributes = new CreateFolderDataAttributes("NET Folder", baseAttribute);
CreateFolderData createFolderData = new CreateFolderData(createFolderDataAttributes, createFolderDataFolderRelationships);
CreateFolder createFolder = new CreateFolder(new JsonApiVersionJsonapi(JsonApiVersionJsonapi.VersionEnum._0), createFolderData);

folderApi.PostFolder(projectId, createFolder);

Is there something I am missing to create a folder with the name "NET Folder"?


Solution

  • The problem was I was using the wrong object body inside the BaseAttributesExtensionObjectWithoutSchemaLink. Instead of using folderInfo.Value.attributes.extension.data, I replaced it with folder.data and it worked after.