Skip to main content
Known Participant
Mar 29, 2024 10:19 PM UTC

How to query collaboration ID for specific folder, file for a specific user?

Hi Team,

Is there a way to query a specific user collaboration ID to a specific folder using Box CLI?

Best Regards

    3 replies

    Apr 5, 2024 9:43 AM UTC

    Hi @user711,

    There is. What are you trying to do? I have some PowerShell that uses the CLI to:

    1. Get all the files and folders a user has shared with them
    2. Pulls out the collaborations on that file
    3. Returns the users who are part of that collaboration

    Is that what you are looking for?

    Regards

    John

    Translate
    user711Author
    Known Participant
    Apr 8, 2024 8:59 PM UTC

    Hi Johan,

    Thanks for you follow up, I have the files and folders ids and I want to get collaboration id for specific users who collaborate these files and folders, currently when I run the CLI command for a specific file or folder, it gives the full list of all collaboration ids instead i need the collaboration ids for specific users.

    Best Regards

    Translate
    Amr Salama Khalil
    Apr 9, 2024 8:24 AM UTC

    I don’t think you can do that. When you get the collaborations back it is a collection so you need to go through and find the individual collaboration that is for your user. This is what I am doing in PowerShell:

    foreach ($collaboration in $collaborations)
    {
        if ($collaboration.accessible_by.id -eq $AsUser)
        {
            "============================================================================="
            $item.id + " - " + $item.name + " - " + $item.type + " - " + $collaboration.role + " - " + $collaboration.accessible_by
            
        }
    }
    
    Translate