Need to see if your shared folder is taking up space on your dropbox 👨💻? Find out how to check here.
Forum Discussion
itsrainman
8 years agoExplorer | Level 3
Share a folder with team members using dropbox api v2.0
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...
Greg-DB
Dropbox Community Moderator
8 years agoCalling these functions would work the same way as the ones you already have, e.g., calling ShareFolderAsync would look like:
Await dbx.Sharing.ShareFolderAsync(path)
Please give that a try. If you run in to any issues writing it, post what you have and the details of what you're stuck on (e.g., the error message, etc.)
itsrainman
8 years agoExplorer | Level 3
Hello Greg,
Many thanks for taking the time to respond. I've been on other stuff and have only managed to get back to this today.
So i used your suggestion.
Await dbx.Sharing.ShareFolderAsync(path)
Replacing path with my folder strFolder (/TempFolder)
Await dbx.Sharing.ShareFolderAsync(strFolder)
As soon as I tested the code it appered in my dropbox information bubble on the taskbar - great.
Now how do i send other users a link to enable them to share this folder. I assume it something along the lines of:
Await dbx.Sharing.AddFolderMemberAsync(strFolder, "someemail@email.com")
However when i get this there is an error with the message below.
System.AggregateException
HResult=0x80131500
Message=One or more errors occurred.
Source=mscorlib
StackTrace:
at System.Threading.Tasks.Task.ThrowIfExceptional(Boolean includeTaskCanceledExceptions)
at System.Threading.Tasks.Task.Wait(Int32 millisecondsTimeout, CancellationToken cancellationToken)
at System.Threading.Tasks.Task.Wait()
at ....
Inner Exception 1:
InvalidCastException: Unable to cast object of type 'System.String' to type 'System.Collections.Generic.IEnumerable`1[Dropbox.Api.Sharing.AddMember]'.
I think its because its not possible to convert the email address which is a string to an iEnumerable(of AddMember).
How do i create a list of email addresses to send the share link to?
- Greg-DB8 years ago
Dropbox Community Moderator
I just dug up this old post where I wrote an example of using MemberSelector and AddMember to specify a member to add via an email address:
https://www.dropboxforum.com/t5/API-Support-Feedback/How-we-share-folder-and-file-via-dropbox-api/m-p/194299/highlight/true#M8768
It also shows how to check the shared folder job, since you need to supply the shared folder ID, not path, when adding a member. Hope this helps! - chirstius8 years ago
Dropbox Staff
Hello itsrainman,
You might want to take a look at the docs for the AddFolderMemberAsync() method. It takes an AddFolderMemberArg as it's parameter.
I'd try constructing a new AddFolderMemberArg, passing that in, and seeing if things work a little better.
Hope that helps,
-Chuck
- itsrainman8 years agoExplorer | Level 3
Many thanks.
Took a look and changed the code as required.
Dim shareFolderLaunch = Await dbx.Sharing.ShareFolderAsync(strFolder) Dim sharedFolderId As String = "" If shareFolderLaunch.IsAsyncJobId Then While True Dim shareFolderJobStatus = dbx.Sharing.CheckShareJobStatusAsync(shareFolderLaunch.AsAsyncJobId.Value) If shareFolderJobStatus.IsFaulted Then Console.WriteLine(("Sharing folder failed: " + shareFolderJobStatus.IsFaulted)) 'return ElseIf shareFolderJobStatus.status = TaskStatus.Running Then Console.WriteLine("Sharing folder in progress...") ' todo: add some delay ElseIf shareFolderJobStatus.IsCompleted Then Console.WriteLine("Sharing folder complete.") sharedFolderId = shareFolderJobStatus.Id Exit While End If End While ElseIf shareFolderLaunch.IsComplete Then sharedFolderId = shareFolderLaunch.AsComplete.Value.SharedFolderId Else 'Return End If Console.WriteLine(("Shared folder with ID: " + sharedFolderId)) Dim members = {New AddMember(New MemberSelector.Email("someemail@email.com"))} Await dbx.Sharing.AddFolderMemberAsync(sharedFolderId, members)All functions and I get an email :)
Just need to code in some error checks for an already shared folder etc, so getting there.
- itsrainman8 years agoExplorer | Level 3
Hello again all,
I have again had some time to spend on this today and I'm a little confused.
I have created a folder, this appears in dropbox and is shared with me.
I next add some files and I can see them if i inspect the folder.
However if I attempt to share the folder with another user via email I get the error "bad_path/already_shared/.."
I am just calling the original code that created the folder and then shared it with the first user - me,. How do i add additional users to the share?
About Dropbox API Support & Feedback
Find help with the Dropbox API from other developers.
The Dropbox Community team is active from Monday to Friday. We try to respond to you as soon as we can, usually within 2 hours.
If you need more help you can view your support options (expected response time for an email or ticket is 24 hours), or contact us on X, Facebook or Instagram.
For more info on available support options for your Dropbox plan, see this article.
If you found the answer to your question in this Community thread, please 'like' the post to say thanks and to let us know it was useful!