Get Collaboration Name and Email Address from .NET SDK
AnsweredHi,
I am using the .NET SDK and am trying to retrieve the collaborations for a folder. How can I get the Name and Login of each collaborator?
I am running the following code:
BoxClient client = await GetBoxClient();
BoxCollection<BoxCollaboration> collaborators = await client.FoldersManager.GetCollaborationsAsync(folderId);
Iterating through the collaborators.Entries, there is an AccessibleBy property. In debug mode, I can see the Name and Login, however I cannot access it directly in my code.
Has anyone had this issue, and if so, how do I fix it?
Thanks.
-
Hi
The object you get in the entries will be a 'BoxEntity' as it could be either a user or a group. It has a 'Type' property you can check and the cast accordingly.
Something like this
collaborators.Entries.ForEach(collaboration =>
{
if(collaboration.AccessibleBy.Type.Equals("user")) {
Console.WriteLine(((BoxUser)collaboration.AccessibleBy).Name + "::" + ((BoxUser)collaboration.AccessibleBy).Login);
}
});Best regards, Peter Christensen, Platform Solutions Engineer, Box
Post is closed for comments.
Comments
1 comment