Regression Bug: JsonSerializationException for GetCurrentUserInformationAsync
See original GitHub issue- I have checked that the SDK documentation doesn’t solve my issue.
- I have checked that the API documentation doesn’t solve my issue.
- I have searched the Box Developer Forums and my issue isn’t already reported (or if it has been reported, I have attached a link to it, for reference).
- I have searched Issues in this repo and my issue isn’t already reported.
Description of the Issue
Just upgrade from Box.V2.Core 3.22.0 to 3.23.0. A regression issue has bubbled up.
I can no longer call var user = await boxClient.UsersManager.GetCurrentUserInformationAsync();
without the a Newtonsoft deserialization issue. See Stack Trace below for further details.
Steps to Reproduce
internal BoxClient GetBoxUserClient(string userID)
{
var boxConfig = new BoxConfig(this.ClientID, this.ClientSecret, this.EnterpriseID, this.PrivateKey, this.PrivateKeyPassphrase, this.PublicKeyID);
var boxJwt = new BoxJWTAuth(boxConfig);
var userToken = boxJwt.UserToken(userID);
return boxJwt.UserClient(userToken, userID);
}
var boxClient = GetBoxUserClient("validuser@mydomain.com");
var user = await boxClient.UsersManager.GetCurrentUserInformationAsync();
Use the above code in version 3.22.0: Works. Use the above code in version 3.23.0: Exception thrown.
Expected Behavior
Not have an exception thrown.
Error Message, Including Stack Trace
Newtonsoft.Json.JsonSerializationException: Cannot deserialize the current JSON array (e.g. [1,2,3]) into type 'Box.V2.Models.BoxNotificationEmail' because the type requires a JSON object (e.g. {"name":"value"}) to deserialize correctly.
To fix this error either change the JSON to a JSON object (e.g. {"name":"value"}) or change the deserialized type to an array or a type that implements a collection interface (e.g. ICollection, IList) like List<T> that can be deserialized from a JSON array. JsonArrayAttribute can also be added to the type to force it to deserialize from a JSON array.
Path 'notification_email', line 1, position 451.
at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.EnsureArrayContract(JsonReader reader, Type objectType, JsonContract contract)
at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateList(JsonReader reader, Type objectType, JsonContract contract, JsonProperty member, Object existingValue, String id)
at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateValueInternal(JsonReader reader, Type objectType, JsonContract contract, JsonProperty member, JsonContainerContract containerContract, JsonProperty containerMember, Object existingValue)
at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.SetPropertyValue(JsonProperty property, JsonConverter propertyConverter, JsonContainerContract containerContract, JsonProperty containerProperty, JsonReader reader, Object target)
at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.PopulateObject(Object newObject, JsonReader reader, JsonObjectContract contract, JsonProperty member, String id)
at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.Populate(JsonReader reader, Object target)
at Newtonsoft.Json.Serialization.JsonSerializerProxy.PopulateInternal(JsonReader reader, Object target)
at Newtonsoft.Json.JsonSerializer.Populate(JsonReader reader, Object target)
at Box.V2.Converter.JsonCreationConverter`1.ReadJson(JsonReader reader, Type objectType, Object existingValue, JsonSerializer serializer)
at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.DeserializeConvertable(JsonConverter converter, JsonReader reader, Type objectType, Object existingValue)
at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.Deserialize(JsonReader reader, Type objectType, Boolean checkAdditionalContent)
at Newtonsoft.Json.JsonSerializer.DeserializeInternal(JsonReader reader, Type objectType)
at Newtonsoft.Json.JsonSerializer.Deserialize(JsonReader reader, Type objectType)
at Newtonsoft.Json.JsonConvert.DeserializeObject(String value, Type type, JsonSerializerSettings settings)
at Newtonsoft.Json.JsonConvert.DeserializeObject(String value, Type type, JsonConverter[] converters)
at Newtonsoft.Json.JsonConvert.DeserializeObject[T](String value, JsonConverter[] converters)
at Box.V2.Converter.BoxJsonConverter.Parse[T](String content)
at Box.V2.Extensions.BoxResponseExtensions.ParseResults[T](IBoxResponse`1 response, IBoxConverter converter)
at Box.V2.Managers.BoxResourceManager.ToResponseAsync[T](IBoxRequest request, Boolean queueRequest)
at Box.V2.Managers.BoxUsersManager.GetCurrentUserInformationAsync(IEnumerable`1 fields)
Screenshots
Versions Used
.Net SDK: .NET Core 3.1.4 Windows: Windows 10 (1909) 64-bit
Issue Analytics
- State:
- Created 3 years ago
- Comments:10 (5 by maintainers)
Top Results From Across the Web
[Bug] Json serializer fails on iOS in release mode (AOT) - ...
Json.JsonSerializationException: Error setting value in extension data for type 'Microsoft.Identity.Client.OAuth2.MsalTokenResponse'.
Read more >All Answers Tagged With Whatever
Don't worry, your conversation data is preserved! ... Invalid package name "__ngcc_entry_points__.json": name cannot start with an underscore ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@sujaygarlanka It’s been over two weeks; any updates?
Truly no worries for me. We aren’t rolling out our Box implementation yet. I just wanted to make sure this wasn’t lost.
Totally understand, and really appreciate the reply. Keep up the good work.