cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Announcements
Want to learn some quick and useful tips to make your day easier? Check out how Calvin uses Replay to get feedback from other teams at Dropbox 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: 

Re: V2 API MembersAddAsync

V2 API MembersAddAsync

schek
Explorer | Level 3
Go to solution

I am adding a team member using .net Dropbox.Api class library. 

I could not figure a way to get IsSuccess or IsUserAlreadyOnTeam properties after MembersAddAsync is called. Since MembersAddAsync method returns the Task type, the only information I can got from the call is IsComplete.

How is it possible to determine if adding a member operation was succesful?

1 Accepted Solution

Accepted Solutions

Greg-DB
Dropbox Staff
Go to solution

You can do something like this:

var membersAddLaunch = await this.client.Team.MembersAddAsync(newMembers);
if (membersAddLaunch.IsComplete) {
    Console.WriteLine ("Adding members is complete.");
    foreach (var memberAdd in membersAddLaunch.AsComplete.Value) {
        if (memberAdd.IsSuccess) {
            Console.WriteLine ("Successfully added:");
            Console.WriteLine (memberAdd.AsSuccess.Value.Profile.Email);
        } else {
            Console.WriteLine (memberAdd);
        }
    }
} else if (membersAddLaunch.IsAsyncJobId) {
    Console.WriteLine ("Adding member via async job with job ID...");
    Console.WriteLine (membersAddLaunch.AsAsyncJobId.Value);
    // todo: poll MembersAddJobStatusGetAsync to get the result
}

View solution in original post

8 Replies 8

Greg-DB
Dropbox Staff
Go to solution

You should poll MembersAddJobStatusGetAsync after MembersAddAsync to get the result.

schek
Explorer | Level 3
Go to solution

Hi Greg, Thank you so much for your reply!

Do you have a sample code on how to get a pollArg parameter from this call? 

 

var Result = await client.Team.MembersAddAsync(iemember);

 

await client.Team.MembersAddJobStatusGetAsync(?);

Greg-DB
Dropbox Staff
Go to solution

I don't have a sample available, but you'll want to use MembersAddLaunch.IsAsyncJobId to check if the MembersAddLaunch you got from MembersAddAsync is an async job ID, and then use MembersAddLaunch.AsAsyncJobId to get the MembersAddLaunch.AsyncJobId, which you can pass to MembersAddJobStatusGetAsync.

schek
Explorer | Level 3
Go to solution

Greg,

 

Thank you for your help.

Unfortunately the Value of IsAsyncJobID is false and AsAsyncJobID is NULL, IsComplete is true after the call.

Not sure how could I get those values.

 

Greg-DB
Dropbox Staff
Go to solution
If IsComplete is true to begin with, you don't need to call MembersAddJobStatusGetAsync, since the operation already completed. Instead, you'd just use MembersAddLaunch.AsComplete to get the added member result.

So, to summarize, when you call MembersAddAsync, the operation will either complete immediately, or if not, it will give you a job ID that you can use with MembersAddJobStatusGetAsync to eventually get the result.

schek
Explorer | Level 3
Go to solution

It looks like the way to access IsSuccess property from AsComplete is:

new System.Collections.Generic.Mscorlib_CollectionDebugView<Dropbox.Api.Team.MemberAddResult>(Result.AsComplete.Value).Items[0].IsSuccess

But it gives me the error: 'Mscorlib_CollectionDebugView<T>' is inaccessible due to its protection level.
Is there something else I am missing?

 

Thank you again.

 

 

 

Greg-DB
Dropbox Staff
Go to solution

You can do something like this:

var membersAddLaunch = await this.client.Team.MembersAddAsync(newMembers);
if (membersAddLaunch.IsComplete) {
    Console.WriteLine ("Adding members is complete.");
    foreach (var memberAdd in membersAddLaunch.AsComplete.Value) {
        if (memberAdd.IsSuccess) {
            Console.WriteLine ("Successfully added:");
            Console.WriteLine (memberAdd.AsSuccess.Value.Profile.Email);
        } else {
            Console.WriteLine (memberAdd);
        }
    }
} else if (membersAddLaunch.IsAsyncJobId) {
    Console.WriteLine ("Adding member via async job with job ID...");
    Console.WriteLine (membersAddLaunch.AsAsyncJobId.Value);
    // todo: poll MembersAddJobStatusGetAsync to get the result
}

schek
Explorer | Level 3
Go to solution

Perfet! This works. Thank you so much!

Need more support?