I am working on an Android app which uses Dropbox Core SDK v3.0.3. While trying to share a folder with another member, I am constantly getting an error. The code is creating a new shared folder in the specified name, but not adding any members.
This is my code:
List<AddMember> list = new ArrayList<AddMember>();
AddMember newMember = new AddMember(MemberSelector.email(clerkDbId), AccessLevel.EDITOR);
list.add(newMember);
ShareFolderLaunch sfl = dbxClient.sharing().shareFolder("/" + clerkName);
dbxClient.sharing().addFolderMember(sfl.getCompleteValue().toString(), list); //I am getting error here.
clerkName: Name of the shared folder
clerkDbId: Dropbox id to which I want to share the above folder
I tried changing the first line to:
ArrayList<AddMember> list = new ArrayList<>();
Still I am getting the same error. This is the error I am getting:
String 'sharedFolderId' does not match pattern java.lang.IllegalArgumentException: String 'sharedFolderId' does not match pattern at com.dropbox.core.v2.sharing.AddFolderMemberArg.(AddFolderMemberArg.java:50) at com.dropbox.core.v2.sharing.AddFolderMemberArg.(AddFolderMemberArg.java:86) at com.dropbox.core.v2.sharing.DbxUserSharingRequests.addFolderMember(DbxUserSharingRequests.java:154) at com.dbapp.ashworth.adminapp.FilesActivity$3$1.doInBackground(FilesActivity.java:126) at com.dbapp.ashworth.adminapp.FilesActivity$3$1.doInBackground(FilesActivity.java:115) at android.os.AsyncTask$2.call(AsyncTask.java:295) at java.util.concurrent.FutureTask.run(FutureTask.java:237) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1113) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:588) at java.lang.Thread.run(Thread.java:818)
Can anyone please tell me what am I doing wrong here?
The error message is indicating that the sharedFolderId
parameter value that you're passing to addFolderMember
doesn't appear to be a valid shared folder ID.
You're passing in the entire SharedFolderMetadata
(as a string). You should instead just get the shared folder ID like this:
sfl.getCompleteValue().getSharedFolderId();
By the way, when calling shareFolder
, you're not guaranteed to get the completed information immediately. You should use ShareFolderLaunch.isComplete
/ShareFolderLaunch.isAsyncJobId
to check what you got back. There's more information in the shareFolder documentation