intercom / intercom-dotnet

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

Unexpected character exception deserializing response from ContactsClient.List() #160

Open iPlexor opened 4 years ago

iPlexor commented 4 years ago

Using the nuget release 2.1.1 and the current master branch, calling List() on ContactsClient results in a sucessful request and response but throws an exception when deserializing the response json into the Contacts class.

Inner Exception Message:

Unexpected character encountered while parsing value: {. Path 'pages.next', line 1, position 18348.

This appears to be due to the v2.0 API returning a 'next' pagination object, rather than a string as expected in the current class data structure.

This can be fixed by providing a Next class as follows:

namespace Intercom.Data
{
    public class Next
    {
        public int page { get; set; }
        public string starting_after { get; set; }
    }
}

and switching next in Page.cs from a string to this the new object like so:

namespace Intercom.Data
{
    public class Pages : Model
    {
        public Next next { get; set; }
        public int page { get; set; }
        public int per_page { get; set; }
        public int total_pages { get; set; }
    }
}

I will prepare a PR for this.