Search code examples
node.jsaccess-tokenautodesk-forge

Forge-Get Item Path along with custom attributes in BIM360 document


Two Requirements are needed:

  1. Get item path of the document in a BIM360 document management.
  2. Get all custom attributes for that item. For Req. 1, an api exists to fetch and for getting custom attributes, another api exists and data can be retrived. Is there a way to get both the requirements in a single api call instead of using two. In case of large number of records, api to retrieve item path is taking more than an hour for fetching 19000+ records and token gets expired though refesh token is used, while custom attribute api processes data in batches of 50, which completes it in 5 minutes only. Please suggest.

Solution

  • Batch-Get Custom Attributes is for the additional attributes of Document Management specific. While path in project is a general information with Data Management.

    The Data Management API provides some endpoints in a format of command, which can ask the backend to process the data for bunch of items. https://forge.autodesk.com/en/docs/data/v2/reference/http/ListItems/

    This command will retrieve metadata for up to 50 specified items one time. It also supports the flag includePathInProject, but the usage is tricky and API document does not indicate it. In the response, it will tell the pathInProject of these items. It may save more time than iteration.

     {
         "jsonapi": {
          "version": "1.0"
     },
      "data": {
    "type": "commands",
    "attributes": {
      "extension": {
        "type": "commands:autodesk.core:ListItems",
        "version": "1.0.0" ,
        "data":{
            "includePathInProject":true
        }
    
      }
    },
    "relationships": {
      "resources": {
        "data": [
          {
            "type": "items",
            "id": "urn:adsk.wipprod:dm.lineage:vkLfPabPTealtEYoXU6m7w"
          },
          {  
            "type": "items",
            "id": "urn:adsk.wipprod:dm.lineage:bcg7gqZ6RfG4BoipBe3VEQ"
          } 
        ]
      }
      }
     }
    }