cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Announcements
Update: Find information on Dropbox support during COVID-19 here
Close

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: 
Highlighted

Trying to add group to the Team Folder using API

Explorer | Level 3

Hi,

I am trying to create a team folder and adding groups to it using API, Creating a team folder works fine, Then for adding groups to the folder, I could not find any API to do that. Can you please provide link to API if there is any?

 

Thanks,

Anusha

5 Replies 5
Highlighted

Re: Trying to add group to the Team Folder using API

Dropboxer
Dropboxer

Hi Anusha, to add a group to a shared or team folder, you should use the /2/sharing/add_folder_member endpoint:

 

https://www.dropbox.com/developers/documentation/http/documentation#sharing-add_folder_member

 

(Click through AddMember and MemberSelector to see more information on specifying the group via a group ID.)

Highlighted

Re: Trying to add group to the Team Folder using API

Explorer | Level 3

I can't get this to work - I've tried everything to add a group to a team folder.  I've looked at other APIs and this is the only one that seems close to doing it.

The AddMember selector mentions only the tags 'dropbox_id' and 'email'.  These are user selectors and not group selectors.  In the web gui, you aren't even allowed to add users to team folders - it must be a group.  

I tried just passing a group_id tagged as 'group_id' but I get a 400:Bad Request error.

I also tried passing a group_id tagged as a 'dropbox_id' but it didn't work either.

$body_req = '{ "shared_folder_id": "4211433992", "members": [ { "member": {".tag": "group_id", "group_id": "g:22f456bfb335a64b000000000009f29e" }, "access_level": { ".tag": "editor"} }]}'

 

 

Highlighted

Re: Trying to add group to the Team Folder using API

Dropboxer
Dropboxer

@jason_nyc Using the group ID as a "dropbox_id" is the right way to add a group to a folder. 

Here's an example of what that would look like:

curl -X POST https://api.dropboxapi.com/2/sharing/add_folder_member \
    --header "Authorization: Bearer <TEAM_MEMBER_FILES_ACCESS_ACCESS_TOKEN>" \
    --header "Dropbox-API-Select-Admin: <ADMIN_MEMBER_ID>" \
    --header "Content-Type: application/json" \
    --data "{\"shared_folder_id\": \"<TEAM_FOLDER_ID>\",\"members\": [{\"member\": {\".tag\": \"dropbox_id\",\"dropbox_id\": \"g:53cf341b5cb2e387000000000000425a\"}}]}"

Can you elaborate on what you mean when you say it didn't work? Please share the full code and output if something isn't working as expected. Make sure you check the response body for an error message.

 

Re: Trying to add group to the Team Folder using API

Explorer | Level 3
Host: https://api.dropboxapi.com
User-Agent: api-explorer-client
Authorization: Bearer K3eIF3qUz8xxxxxxxxxxxxxxxxxxxxxxxxx
Content-Type: application/json

{
    "shared_folder_id": "4968278384",
    "members": [
        {
            "member": {
                ".tag": "dropbox_id",
                "dropbox_id": "g:22f456bfb225a64b000000000009f325"
            }
        }
    ]
}

tried this from the api explorer and get this

	
{
  "error_summary": "access_error/not_a_member/...",
  "error": {
    ".tag": "access_error",
    "access_error": {
      ".tag": "not_a_member"
    }
  },
  "user_message": {
    "locale": "en",
    "text": "You aren’t a member of this shared folder."
  }
}

I'm trying to do this as a Team admin

 

 

When I do this in powershell i get

$Token = 'K3eIF3qUz8AAxxxxxxxxxxxxxxx'
$uri='https://api.dropboxapi.com/2/sharing/add_folder_member'
$body_req='{"shared_folder_id": "4968278384", "members": [ { "member": {".tag": "dropbox_id", "dropbox_id": "g:22f456bfb225a64b000000000009f325" }}]}'
$res = Invoke-RestMethod -Uri $uri -Body $body_req -ContentType 'application/json' -Headers @{ Authorization = ("Bearer " + $Token) } -Method Post
Invoke-RestMethod : The remote server returned an error: (409) Conflict.
At line:1 char:8
Highlighted

Re: Trying to add group to the Team Folder using API

Dropboxer
Dropboxer

@jason_nyc Thanks for the code/output! I see you're trying to operate on a team folder using a user-linked "Dropbox API" app. To perform this operation, you'd need to use a "Dropbox Business API" with the 'team member file access' permission, using the "Dropbox-API-Select-Admin" header, like in my the example in my previous post.

By the way, the two attempt you shared here are probably the same error. In the PowerShell attempt you don't seem to be printing the response body, but I expect it would contain the same error.

Polls
Do you know how to organize your files and folders?
We have created a guide on folder best practice, so you can get organized now check it out here.

Work Smarter with Dropbox

The way we work is changing. Share and discover new ways to work smarter with Dropbox in our community.

Sound good? Let's get started.
Need more support?