cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Announcements
If you’ve changed your email address, now's the perfect time to update it on your Dropbox account and we’re here to help! Learn more here.

Dropbox API Support & Feedback

Find help with the Dropbox API from other developers.

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Re: Target team folders without namespace

Target team folders without namespace

noelbuergler
Explorer | Level 3
Go to solution

Hi,

We are currently utilizing the Dropbox API to lock files within our team folder structure. For example, to lock the file located at:

/Soft launch/_2024-06-17_Dropbox-Tests/2024-06-17_Dropbox-Test Leerzeichen.indd

(full path: /Users/noel/Library/CloudStorage/Dropbox-Linkgroup/Soft launch/_2024-06-17_Dropbox-Tests/2024-06-17_Dropbox-Test Leerzeichen.indd)

 

We use the following curl command:

curl -X POST https://api.dropboxapi.com/2/files/lock_file_batch \

    -H "Authorization: Bearer YOUR_ACCESS_TOKEN" \

    -H "Content-Type: application/json" \

    -H "Dropbox-API-Select-User: YOUR_USER_ID" \

    -H "Dropbox-API-Path-Root: {\".tag\": \"namespace_id\", \"namespace_id\": \"4662013585\"}" \

    -d '{

          "entries": [

              {

                  "path": "/_2024-06-17_Dropbox-Tests/2024-06-17_Dropbox-Tests.indd"

              }

          ]

       }'

 

We identified the namespace ID for the "Soft launch" folder (4662013585) using the following command:

curl -X POST https://api.dropboxapi.com/2/team/team_folder/list \

    -H "Authorization: Bearer YOUR_ACCESS_TOKEN" \

    -H "Content-Type: application/json" \

    -d '{}'

 

We aim to simplify this process by locking files without specifying the Dropbox-API-Path-Root header and namespace ID, ideally using the full path directly:

curl -X POST https://api.dropboxapi.com/2/files/lock_file_batch \

    -H "Authorization: Bearer YOUR_ACCESS_TOKEN" \

    -H "Content-Type: application/json" \

    -H "Dropbox-API-Select-User: YOUR_USER_ID" \

    -d '{

          "entries": [

              {

                  "path": "/Soft launch/_2024-06-17_Dropbox-Tests/2024-06-17_Dropbox-Test Leerzeichen.indd"

              }

          ]

       }'

 

From the Dropbox API documentation, we understand that paths should be relative to the application's root, either an app folder or the root of a user's Dropbox, depending on the app's access type.
However, our attempts without the namespace ID have resulted in errors indicating that the path is not found. Is there a possible way other than creating “another” root folder?

Thanks!

1 Accepted Solution

Accepted Solutions

Greg-DB
Dropbox Staff
Go to solution

It looks like you're trying to operate on files inside the "team space". In order to access the team space, you do need to use the "Dropbox-API-Path-Root" header. It's not possible to access the contents of the team space without using the "Dropbox-API-Path-Root" header, but there are different ways to use the "Dropbox-API-Path-Root" header.

 

For example, you can use the "root" mode (instead of the "namespace_id" mode like you have in your sample) to access the root namespace for an account, which would be the team space for an account on a team using a team space configuration.

 

You can get the root_namespace_id for an account by calling /2/users/get_current_account for that account, and then plug that in to the "Dropbox-API-Path-Root" header on subsequent calls. You can find more information on how to use this functionality in the Team Files Guide.

 

When doing so, you should then supply the path value relative to that root. So for your example, that would look like:

curl -X POST https://api.dropboxapi.com/2/files/lock_file_batch \
    -H "Authorization: Bearer YOUR_ACCESS_TOKEN" \
    -H "Content-Type: application/json" \
    -H "Dropbox-API-Select-User: YOUR_USER_ID" \
    -H "Dropbox-API-Path-Root: {\".tag\": \"root\", \"root\": \"ROOT_NAMESPACE_ID\"}" \
    -d '{
          "entries": [
              {
                  "path": "/Soft launch/_2024-06-17_Dropbox-Tests/2024-06-17_Dropbox-Test Leerzeichen.indd"
              }
          ]
       }'

 

View solution in original post

2 Replies 2

Greg-DB
Dropbox Staff
Go to solution

It looks like you're trying to operate on files inside the "team space". In order to access the team space, you do need to use the "Dropbox-API-Path-Root" header. It's not possible to access the contents of the team space without using the "Dropbox-API-Path-Root" header, but there are different ways to use the "Dropbox-API-Path-Root" header.

 

For example, you can use the "root" mode (instead of the "namespace_id" mode like you have in your sample) to access the root namespace for an account, which would be the team space for an account on a team using a team space configuration.

 

You can get the root_namespace_id for an account by calling /2/users/get_current_account for that account, and then plug that in to the "Dropbox-API-Path-Root" header on subsequent calls. You can find more information on how to use this functionality in the Team Files Guide.

 

When doing so, you should then supply the path value relative to that root. So for your example, that would look like:

curl -X POST https://api.dropboxapi.com/2/files/lock_file_batch \
    -H "Authorization: Bearer YOUR_ACCESS_TOKEN" \
    -H "Content-Type: application/json" \
    -H "Dropbox-API-Select-User: YOUR_USER_ID" \
    -H "Dropbox-API-Path-Root: {\".tag\": \"root\", \"root\": \"ROOT_NAMESPACE_ID\"}" \
    -d '{
          "entries": [
              {
                  "path": "/Soft launch/_2024-06-17_Dropbox-Tests/2024-06-17_Dropbox-Test Leerzeichen.indd"
              }
          ]
       }'

 

noelbuergler
Explorer | Level 3
Go to solution

**bleep** Greg-DB you are awesome! Everything worked like a charm and it is exactly what I needed.

Regards,
Noel

 

Need more support?