intercom / intercom-dotnet

Intercom API client library for .NET
https://developers.intercom.io/reference
Apache License 2.0
63 stars 54 forks source link

Newtonsoft.Json.JsonSerializationException: Error converting value {null} to type 'System.Boolean'. Path 'users[0].marked_email_as_spam' #171

Open dradovic opened 2 years ago

dradovic commented 2 years ago

For some old contacts (> 5 yrs), we get the following error when trying to list a user:

Intercom.Exceptions.IntercomException: An exception occurred while calling the endpoint. Method: GET, Url: https://api.intercom.io/, Resource: users, Sub-Resource:

I guess that marked_email_as_spam should be declared as a nullable boolean to support the loading of older contacts.

This is the call-stack:

Intercom.Exceptions.IntercomException: An exception occurred while calling the endpoint. Method: GET, Url: https://api.intercom.io/, Resource: users, Sub-Resource:
---> Newtonsoft.Json.JsonSerializationException: Error converting value {null} to type 'System.Boolean'. Path 'users[0].marked_email_as_spam', line 1, position 978.
---> System.InvalidCastException: Null object cannot be converted to a value type.
at System.Convert.ChangeType(Object value, Type conversionType, IFormatProvider provider)
at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.EnsureType(JsonReader reader, Object value, CultureInfo culture, JsonContract contract, Type targetType)
--- End of inner exception stack trace ---
at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.EnsureType(JsonReader reader, Object value, CultureInfo culture, JsonContract contract, Type targetType)
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.CreateObject(JsonReader reader, Type objectType, JsonContract contract, JsonProperty member, JsonContainerContract containerContract, JsonProperty containerMember, Object existingValue)
at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.PopulateList(IList list, JsonReader reader, JsonArrayContract contract, JsonProperty containerProperty, String id)
at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateList(JsonReader reader, Type objectType, JsonContract contract, JsonProperty member, Object existingValue, String id)
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.CreateObject(JsonReader reader, Type objectType, JsonContract contract, JsonProperty member, JsonContainerContract containerContract, JsonProperty containerMember, 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.JsonConvert.DeserializeObject(String value, Type type, JsonSerializerSettings settings)
at Intercom.Core.Client.Deserialize[T](String data)
at Intercom.Core.Client.HandleNormalResponse[T](IRestResponse response)
at Intercom.Core.Client.HandleResponse[T](IRestResponse response)
at Intercom.Core.Client.Get[T](Dictionary`2 headers, Dictionary`2 parameters, String resource)
--- End of inner exception stack trace ---
at Intercom.Core.Client.Get[T](Dictionary`2 headers, Dictionary`2 parameters, String resource)
at Intercom.Clients.UsersClient.List(Dictionary`2 parameters)