Event Deserialization issue

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • jsr84
    Junior Member
    • Nov 2021
    • 3

    #1

    Event Deserialization issue

    Using the c# library from Api_ng_sample_code
    Calling client.listEvents(marketFilter, null);

    With a simple filter I get back a list of 100+ Event objects but each has all its properties set to NULL

    eg
    CountryCode null string
    Id null string
    Name null string
    OpenDate null System.DateTime?
    Timezone null string
    Venue null string


    If i debug into the code I can see the JSON string looks as expected eg :
    [
    [{"event":{"id":"31351518","name":"Livingston v Motherwell","countryCode":"GB","timezone":"GMT","o penDate":"2022-04-09T14:00:00.000Z"},"marketCount":15},{"event":{"id ":"31351519","name":"Dundee Utd v Dundee","countryCode":"GB","timezone":"GMT","openD ate":"2022-04-09T14:00:00.000Z"},"marketCount":15},{"event":{"id ":"31351509","name":"Aberdeen v Ross Co","countryCode":"GB","timezone":"GMT","openDate" :"2022-04-09T14:00:00.000Z"},"marketCount":15},
    etc ....

    But then isn't being converted to Event objects by Newtonsoft.Json.JsonConvert.DeserializeObject<T>
    Anyone seen this before or know what could be issue?
    this is all within the standard Api_ng_sample_code library

    I see the same with both the RPC and Rescript clients

    Thanks

  • jsr84
    Junior Member
    • Nov 2021
    • 3

    #2
    Resolved this in case it helps anyone else.

    The code is trying to parse the results to the wrong type. The JSON being returned by listEvent is a list of <EventResult> not a list of <Event>

    so needs to be
    IList<EventResult> listEvents(MarketFilter marketFilter, string locale = null);

    Then works fine

    Comment

    Working...
    X