Skip to content

System.NotSupportedException when fetching player data #4

@SvenTitz

Description

@SvenTitz

When calling PlayersClient.GetOrFetchPlayerAsync(tag, cancellationToken), I get a System.NotSupportedException during JSON deserialization.
The exception indicates that an unsupported System.DateTime member is being encountered inside a custom converter used by CocApi (likely LegendLeagueTournamentSeasonResultJsonConverter or PlayerLegendStatisticsJsonConverter).

System.NotSupportedException: Specified method is not supported. The unsupported member type is located on type 'System.DateTime'. Path: $ | LineNumber: 0 | BytePositionInLine: 12.
 ---> System.NotSupportedException: Specified method is not supported.
   at System.Text.Json.Serialization.JsonConverter`1.ReadCore(Utf8JsonReader& reader, JsonSerializerOptions options, ReadStack& state)
   --- End of inner exception stack trace ---
   at System.Text.Json.ThrowHelper.ThrowNotSupportedException(ReadStack& state, Utf8JsonReader& reader, NotSupportedException ex)
   at System.Text.Json.Serialization.JsonConverter`1.ReadCore(Utf8JsonReader& reader, JsonSerializerOptions options, ReadStack& state)
   at System.Text.Json.JsonSerializer.Read[TValue](Utf8JsonReader& reader, JsonTypeInfo`1 jsonTypeInfo)
   at CocApi.Rest.Models.LegendLeagueTournamentSeasonResultJsonConverter.Read(Utf8JsonReader& utf8JsonReader, Type typeToConvert, JsonSerializerOptions jsonSerializerOptions)
   at System.Text.Json.Serialization.JsonConverter`1.TryRead(Utf8JsonReader& reader, Type typeToConvert, JsonSerializerOptions options, ReadStack& state, T& value, Boolean& isPopulatedValue)
   at System.Text.Json.Serialization.JsonConverter`1.ReadCore(Utf8JsonReader& reader, JsonSerializerOptions options, ReadStack& state)
   at System.Text.Json.JsonSerializer.Read[TValue](Utf8JsonReader& reader, JsonTypeInfo`1 jsonTypeInfo)
   at CocApi.Rest.Models.PlayerLegendStatisticsJsonConverter.Read(Utf8JsonReader& utf8JsonReader, Type typeToConvert, JsonSerializerOptions jsonSerializerOptions)
   at System.Text.Json.Serialization.JsonConverter`1.TryRead(Utf8JsonReader& reader, Type typeToConvert, JsonSerializerOptions options, ReadStack& state, T& value, Boolean& isPopulatedValue)
   at System.Text.Json.Serialization.JsonConverter`1.ReadCore(Utf8JsonReader& reader, JsonSerializerOptions options, ReadStack& state)
   at System.Text.Json.JsonSerializer.Read[TValue](Utf8JsonReader& reader, JsonTypeInfo`1 jsonTypeInfo)
   at CocApi.Rest.Models.PlayerJsonConverter.Read(Utf8JsonReader& utf8JsonReader, Type typeToConvert, JsonSerializerOptions jsonSerializerOptions)
   at System.Text.Json.Serialization.JsonConverter`1.TryRead(Utf8JsonReader& reader, Type typeToConvert, JsonSerializerOptions options, ReadStack& state, T& value, Boolean& isPopulatedValue)
   at System.Text.Json.Serialization.JsonConverter`1.ReadCore(Utf8JsonReader& reader, JsonSerializerOptions options, ReadStack& state)
   at System.Text.Json.JsonSerializer.ReadFromSpan[TValue](ReadOnlySpan`1 json, JsonTypeInfo`1 jsonTypeInfo)
   at CocApi.Rest.Apis.PlayersApi.GetPlayerApiResponse.Ok()
   at CocApi.Cache.PlayersClient.GetOrFetchPlayerAsync(String tag, CancellationToken cancellationToken)

To Reproduce:

Call CocApi.Cache.PlayersClient.GetOrFetchPlayerAsync with one of these two player tags: #2QVRQCJJ, #YUCC0R0PQ
Alternatively I can provide you with an official coc api response for one of these players response.json


Environment:

  • CocApi version: 2.12
  • CocApi.Cache version: 2.12
  • .NET version: .NET 8
  • Database: MariaDB (although not directly related)

Additional Context:

I am also using Caching and the two players show up in the player table with empty (null) ClanTag and RawContent. The StatusCode is 0.


Please let me know if you need help reproducing this error or need any other additional information.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions