box / box-windows-sdk-v2

Windows SDK for v2 of the Box API. The SDK is built upon .NET Framework 4.5

Home Page:https://developer.box.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Cannot Roll Users Out of Enterprise

g1t-out opened this issue · comments

Description of the Issue

I don't seem to be able to roll users out with the Box V2 .Net SDK SDK. If I take the same exact key and use it with the Python SDK, it seems to work fine. The Box V2 .Net SDK indicates it successfully updated the user but nothing changes. Even the Box Admin report indicate the user changed, but they are still in the enterprise. I went through and modified my request to have it change the user's name and that worked fine, but it didn't roll the user out still.

Steps to Reproduce

The code that is making the change is currently:

var updates = new BoxUserRequest()
{
    Id = boxId,
    Name = "Test Box Rollout",
    Enterprise = null
};
try
{
    //Rolling the user out
    BoxUser updatedUser = adminClient.UsersManager.UpdateUserInformationAsync(updates).GetAwaiter().GetResult();
}
catch (Exception Ex)
{
    Logger.LogError(methodName + ": Error rolling user out of enterprise " + Email + " Exception: " + Ex.Message.ToString());
}

Expected Behavior

It updated the user's name in Box, but did not roll them out. If we remove the Name from the BoxUserRequest, it will do nothing to the user's account at all.

Versions Used

.Net SDK: Box.V2 version 3.25.0. The application is targeting .Net Framework 4.6.1
Windows: Windows Server 2016 Version 1607

@jblack6-byu We are taking a look at this issue and will get back to you ASAP.

I've submitted a pull request to fix this issue: #709 . The problem occurs because the Serialize function under Box.V2.Converter.BoxJsonConverter is set to ignore null values. Thus we pass a null in and it ignores it and never puts it on the request. To get around this, I've created a separate UserRequestEntity class and am looking for that class in the BoxJsonConverter. If I see it, I don't pass the option to ignore nulls in the conversion to a JSON string.

My solution is probably not the most elegant as I'm not a great programmer nor am I well versed in C#. Hope this helps. Thanks!

Fixed via #792