intercom / intercom-dotnet

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

Deserialize Exception: UserList.Scroll Response total_count field is null #146

Closed nicholi closed 5 years ago

nicholi commented 5 years ago

This sounds more like an API error on Intercom's end. I haven't looked to see if they changed anything about their guarantee of the "total_count" field.

It also sounds semi-related to the previous mention of null UserLists (https://github.com/intercom/intercom-dotnet/issues/140), which I guess was also an error on Intercom's end. I've tested the actual response from api.intercom.com and the "total_count" field in the response is null. The list is also not empty in the slightest, and it does return a "scroll_param" and all the other typical fields you would expect.

Obviously this is hitting an exception when attempting to deserialize because the "total_count" field on intercom-dotnet Models class is just an int, and not a nullable int.

I've found that many libraries for REST APIs will almost always make all value-type fields as Nullable. Just to ensure deserialization won't freak out like this. It may be something to consider.

Edit: Forgot to mention it is specifically the scroll API for users, not the normal users call.

jpasichnyk commented 5 years ago

I'm blocked by the same issue, since December 11th.

realnickivanov commented 5 years ago

As a workaround you can set global default JsonConvert.DefaultSettings = () => new JsonSerializerSettings { NullValueHandling = NullValueHandling.Ignore }; Or replace Deserialize method via overriding HandleResponse method See https://github.com/intercom/intercom-dotnet/blob/master/src/Intercom/Core/Client.cs

apassant commented 5 years ago

Thanks for reporting this. We're currently working on an API update that should fix this ASAP. We'll let you know 👍

jpasichnyk commented 5 years ago

@apassant @Nicholi This is working again now.

apassant commented 5 years ago

Thanks for confirming. We've fixed the issue in the API, so everything should indeed be back to normal, w/o required SDK update.

MennoKlup commented 4 years ago

I would like to report that this is still the case? total_count is 0