Skip to main content
Solved

"path-collection" is empty when getting a file resourse using "box-node-sdk"


We are building an Integration in the box cloud:

1. Application Type: Custom App

2. Authentication Type: OAuth 2.0

3. Context Menu items are added using “Web Integration”


The Web Integration (Context Menu) Configuration is:



  1. Supports all file extensions

  2. Integration Type is “Files”


We are using BOX-NODE-SDK, to get the file details from the received fileId.


On click of the web-integration, we received the authCode and fileIdin the API.,

Using the AuthCode, we successfully fetched the AccessToken.


const sdk = new BoxSDK({

        clientID: BOX_INTEGRATION_CLIENT_ID,

        clientSecret: BOX_INTEGRATION_CLIENT_SECRET,

});



sdk.getTokensAuthorizationCodeGrant(authCode, null, function (err, tokenInfo) {

  const boxClient = sdk.getPersistentClient(tokenInfo);



  boxClient.files.get(fileId).then((file: any) => {

        logger.info(file);

  })

}


The above code sample returns the file details, but the path-collection is missing in the response.


Under the path-collection object, the entries array is empty and total_count is 0.


{

    etag: "1"

    extension: "txt"

    file_version: {

       id: "***"

       sha1: "***"

       type: "file_version"

    }

    id: "***"

    lock: null

    name: "sample.txt"

    path_collection: {

        entries: [],

        total_count: 0

    }

    size: 7

    type: "file"

    version_number: "2"

}


But, as per the below image - the file is nested under multiple folders.

Any Idea what I am missing here?


Best answer by sarin-vt

Issue resolved.


I was using the wrong configuration in the web integration.


Integration → Integration Scopes → “The parent folder of the file/folder from which this integration is invoked” is the right setup.


I was using → “The file/folder from which this integration is invoked”


Changing this configuration, resolved my issue. I am getting the complete Path now.


View original
Did this topic help you find an answer to your question?

5 replies

  • Author
  • Known Participant
  • 17 replies
  • May 8, 2024

@rbarbosa , @smartoneinok can you please help me here?


This is blocking my integration development.


smartoneinok Box
Forum|alt.badge.img

When you use the web app integration, what user are using? Are you using the admin who owns the file or just a user that is collaborated?


  • Author
  • Known Participant
  • 17 replies
  • May 8, 2024

@smartoneinok I am currently testing the integration with the Admin user, who is the owner of the file.


I tried to add multiple collaborators, but integration is not visible to them.


Please help me understand, how the path or any other field is different for each user role.


  • Author
  • Known Participant
  • 17 replies
  • Answer
  • May 9, 2024

Issue resolved.


I was using the wrong configuration in the web integration.


Integration → Integration Scopes → “The parent folder of the file/folder from which this integration is invoked” is the right setup.


I was using → “The file/folder from which this integration is invoked”


Changing this configuration, resolved my issue. I am getting the complete Path now.



system
  • Community Manager
  • 22 replies
  • May 13, 2024

This topic was automatically closed 4 days after the last reply. New replies are no longer allowed.


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings