We are aware of the issue with the badge emails resending to everyone, we apologise for the inconvenience - learn more here.

Forum Discussion

parimisatya's avatar
parimisatya
Explorer | Level 3
5 years ago

How to assign access level permission while sharing the file to the members

Hi

How to assign access level permission while sharing the file to the members using API

I have done in c# and code is here.

 

using (var dbx = new DropboxClient(token))
{
var shareFolderLaunch = await dbx.Sharing.ShareFolderAsync("/CloudPOC");

var sharedFolderId = "";
if (shareFolderLaunch.IsAsyncJobId)
{
while (true)
{
var shareFolderJobStatus = await dbx.Sharing.CheckShareJobStatusAsync(shareFolderLaunch.AsAsyncJobId.Value);
if (shareFolderJobStatus.IsFailed)
{
Console.WriteLine("Sharing folder failed: " + shareFolderJobStatus.AsFailed.Value);
return;
}
else if (shareFolderJobStatus.IsInProgress)
{
Console.WriteLine("Sharing folder in progress...");
// todo: add some delay
}
else if (shareFolderJobStatus.IsComplete)
{
Console.WriteLine("Sharing folder complete.");
sharedFolderId = shareFolderJobStatus.AsComplete.Value.SharedFolderId;
break;
}
}
}
else if (shareFolderLaunch.IsComplete)
{
sharedFolderId = shareFolderLaunch.AsComplete.Value.SharedFolderId;
}
else
{
return;
}

Console.WriteLine("Shared folder with ID: " + sharedFolderId);

var members = new[] { new AddMember(new MemberSelector.Email("example@xxx.com")) };
var access_level = "viewer";
var add_message_as_comment = false;
await dbx.Sharing.AddFolderMemberAsync(sharedFolderId, members,true);
}