Level up your Box knowledge with brand new learning paths on Box University. Visit training.box.com to get started

Using C# to get user information

Answered
New post

Comments

2 comments

  • bibek_k

    Hi,

     

    I had this problem before and I ended up editing the SDK code itself. 

    Go to   box-windows-sdk-v2\Box.V2\Managers  folder and make changes to BoxUsersManager.cs file

    public async Task GetCurrentUserInformationAsync(List fields = null)
    {
    BoxRequest request = new BoxRequest(_config.UserEndpointUri, "me")
    .Param(ParamFields, fields);

    IBoxResponse response = await ToResponseAsync(request).ConfigureAwait(false);

    return response.ResponseObject;
    }

     

    and you can call this function as :

    var bu = await SymBoxManager.Client.UsersManager.GetCurrentUserInformationAsync(new List() { "login", "space_used", "is_Platform_access_only" });

    console.writeline(bu.is_platform_access_only)

     

    Not exactly the way to do this but I didn't have any choice. You could probaly use inheritence and override the function yourself but i haven't tried it yet. let me know if you do that way.

     

    Hope this helps.

     

    thanks, 

    Bibek

    0
    Comment actions Permalink
  • JoyMDA

    Hi Bibek,

     

    Based on your suggestion, I did the function overloading on the method

    BoxUsersManager.GetUserInformationAsync. See the method definition below. It works well.

     

    Thanks!

     

    Joy

     

     

    //

    /// Retrieves information about a user in the enterprise. Requires enterprise administration authorization.

    ///

    /// userId">The user identifier.

    /// // fields">Attribute(s) to include in the response.

    /// Returns the complete user object.

    public async Task<BoxUser> GetUserInformationAsync(string userId, List<string> fields = null)

    {

    BoxRequest request = new BoxRequest(_config.UserEndpointUri, userId)

    .Param(ParamFields, fields);

    IBoxResponse<BoxUser> response = await ToResponseAsync<BoxUser>(request).ConfigureAwait(false);

    return response.ResponseObject;

    }

     

    0
    Comment actions Permalink

Please sign in to leave a comment.