cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Announcements
Share your feedback on the Document Scanning Experience in the Dropbox App right 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: 

Share a folder with team members using dropbox api v2.0

Share a folder with team members using dropbox api v2.0

itsrainman
Explorer | Level 3

Hello,

 

I am trying to create an app that will run on a internal remote server. The app 'listens' for XML files being generated by our BMS system and then processes these as required.

 

The next add on for the app, it is already running is to make use of the XML files above to create folders, share the folder with team members and then add in files for the team members to modify.

 

I use Visual Basic and have figuered out to create a folder which then appears in windows explorer. I have put a small delay after the folder creation so that enough time is given for the folder to sync back from dropbox.

 

I next want to share it with one of our team members which i assume i will do via thier email address.

 

So my code so far is,

 

 

Public Shared Sub Main(ByVal args As String())
        Dim GetDetails = Threading.Tasks.Task.Run(CType(AddressOf ProcessingForm.GetID, Func(Of Threading.Tasks.Task)))
        GetDetails.Wait()
End Sub

Private Shared Async Function GetID() As Task(Of Threading.Tasks.Task)
        Using dbx = New DropboxClient("My Token")
            Dim strFolder As String = "/TempFolder"
            Dim full = Await dbx.Users.GetCurrentAccountAsync()
            Console.WriteLine("{0} - {1}", full.Name.DisplayName, full.Email)
            If Directory.Exists("C:\Users\Somesubfolder\" & strFolder) Then
                ' This path is a directory.

            Else
                Await dbx.Files.CreateFolderAsync(strFolder, False)
                Thread.Sleep(1000)
            End If

            Await ListRootFolder(dbx)
        End Using
    End Function

    Private Shared Async Function ListRootFolder(ByVal dbx As DropboxClient) As Threading.Tasks.Task
        Dim list = Await dbx.Files.ListFolderAsync(String.Empty)

        For Each item In list.Entries.Where(Function(i) i.IsFolder)
            Console.WriteLine("D  {0}/", item.Name)
        Next

        For Each item In list.Entries.Where(Function(i) i.IsFile)
            Console.WriteLine("F{0,8} {1}", item.AsFile.Size, item.Name)
        Next
    End Function

    Public Async Sub CreateANewFolder(ByVal token As String, ByVal path As String)
        Using dbx = New DropboxClient(token)
            Dim created = Await dbx.Files.CreateFolderAsync(path)
        End Using
    End Sub

I run 'Main' which checks I am a user, creates the folder if it does not exisit and then lists all the folders within my dropbox account.

 

Could someone point me in the direction of how to invite team members to this folder so they can edit the files it contains.

 

A code example would be very useful.

 

Many thanks.

 

 

 

10 Replies 10

chirstius
Dropbox Staff

Actually, re-reading what you posted @itsrainman-

 

Once you have shared the folder via ShareFolderAsync() (what I think you're calling "creating" it) you do not need to call that method again. It's already shared (as the response you're getting implies). You just need to make the call to AddFolderMemberAsync() with any new members you want to share the folder with.

 

Can you confirm if you're getting the error as a result of additional calls to ShareFolderAsync()? If so, I think that's where the issue lies.

 

Thanks,

 

-Chuck

Need more support?
Who's talking

Top contributors to this post

  • User avatar
    chirstius Dropbox Staff
  • User avatar
    itsrainman Explorer | Level 3
What do Dropbox user levels mean?