Skip to content

Cannot validate address because of response deserialization error - .NET 9 and .NET 10 #5

@MiblaCz

Description

@MiblaCz

I tried to validate address, but there is problem with response deserialization.
Tested in .NET 9 and .NET 10.
There is problem with required property Headers.

System.Text.Json.JsonException
  HResult=0x80131500
  Zpráva=JSON deserialization for type 'FoxentrySdk.Services.LocationService+LocationValidationResponse' was missing required properties including: 'headers'.
  Zdroj=System.Text.Json
  StackTrace:
   v System.Text.Json.ThrowHelper.ThrowJsonException_JsonRequiredPropertyMissing(JsonTypeInfo parent, BitArray assignedOrNotRequiredPropertiesSet)
   v System.Text.Json.Serialization.Converters.ObjectDefaultConverter`1.OnTryRead(Utf8JsonReader& reader, Type typeToConvert, JsonSerializerOptions options, ReadStack& state, T& value)
   v System.Text.Json.Serialization.JsonConverter`1.TryRead(Utf8JsonReader& reader, Type typeToConvert, JsonSerializerOptions options, ReadStack& state, T& value, Boolean& isPopulatedValue)
   v System.Text.Json.Serialization.Metadata.JsonPropertyInfo`1.ReadJsonAndSetMember(Object obj, ReadStack& state, Utf8JsonReader& reader)
   v System.Text.Json.Serialization.Converters.ObjectDefaultConverter`1.OnTryRead(Utf8JsonReader& reader, Type typeToConvert, JsonSerializerOptions options, ReadStack& state, T& value)
   v System.Text.Json.Serialization.JsonConverter`1.TryRead(Utf8JsonReader& reader, Type typeToConvert, JsonSerializerOptions options, ReadStack& state, T& value, Boolean& isPopulatedValue)
   v System.Text.Json.Serialization.JsonConverter`1.ReadCore(Utf8JsonReader& reader, T& value, JsonSerializerOptions options, ReadStack& state)
   v System.Text.Json.Serialization.Metadata.JsonTypeInfo`1.ContinueDeserialize[TReadBufferState,TStream](TReadBufferState& bufferState, JsonReaderState& jsonReaderState, ReadStack& readStack, T& value)
   v System.Text.Json.Serialization.Metadata.JsonTypeInfo`1.<DeserializeAsync>d__1`2.MoveNext()
   v System.Runtime.CompilerServices.ConfiguredValueTaskAwaitable`1.ConfiguredValueTaskAwaiter.GetResult()
   v System.Net.Http.Json.HttpContentJsonExtensions.<ReadFromJsonAsyncCore>d__12`1.MoveNext()
   v FoxentrySdk.Core.HttpRequest.<Request>d__7`1.MoveNext()
   v FoxentrySdk.Services.LocationService.<LocationValidation>d__4.MoveNext()
   v Program.<Main>d__1.MoveNext() v souboru C:\!!!Projekty\dotnet10\Foxentry\Program.cs: řádek 67

Sample code:

        var config = new OpenAPIConfig();
        config.SetTokenValue("my api key");
        var sdk = new FoxentrySdk.Sdk(config);
        
        try
        {
            FoxentrySdk.Services.LocationService.LocationValidationRequestBody requestBody = new()
            {
                Request = new FoxentrySdk.Models.LocationValidationRequest
                {
                    Query = new FoxentrySdk.Models.LocationValidationRequest.LocationValidationRequestQuery
                    {
                        StreetWithNumber = "Ulice 1234/12",
                        City = "Mesto",
                        Country = "CZ"
                    },
                    Options = new FoxentrySdk.Models.LocationValidationRequest.LocationValidationRequestOptions
                    {
                        AcceptPostOfficeAsCity = true,
                        CityFormat = FoxentrySdk.Models.LocationRequestOptions.LocationRequestOptionsCityFormat.BASIC,
                        ZipFormat = true,
                    }
                }
            };
            var response = await sdk.Location.LocationValidation(
                requestBody, true
            );

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions