Hello,
I’ve got a weird behavior when transfering GUID values over JsonServiceClient after updating API to ServiceStack v8.
When I call request, that has GUID value in body, it fails with error:
400 Bad Request
Code: SerializationException, Message: Could not deserialize 'application/json' request using SoftProgres.Web.ServiceModel.Dtos.UpdateProductInstallationLogin'
Error: The JSON value could not be converted to System.Guid. Path: $.Id | LineNumber: 0 | BytePositionInLine: 54.
Meta:
InnerMessages: The JSON value could not be converted to System.Guid. Path: $.Id | LineNumber: 0 | BytePositionInLine: 54.
The JSON value is not in a supported Guid format.
Server StackTrace:
System.Runtime.Serialization.SerializationException: Could not deserialize 'application/json' request using SoftProgres.Web.ServiceModel.Dtos.UpdateProductInstallationLogin'
Error: The JSON value could not be converted to System.Guid. Path: $.Id | LineNumber: 0 | BytePositionInLine: 54.
---> System.Text.Json.JsonException: The JSON value could not be converted to System.Guid. Path: $.Id | LineNumber: 0 | BytePositionInLine: 54.
---> System.FormatException: The JSON value is not in a supported Guid format.
at System.Text.Json.ThrowHelper.ThrowFormatException(DataType dataType)
at System.Text.Json.Utf8JsonReader.GetGuid()
at System.Text.Json.Serialization.Metadata.JsonPropertyInfo`1.ReadJsonAndSetMember(Object obj, ReadStack& state, Utf8JsonReader& reader)
at System.Text.Json.Serialization.Converters.ObjectDefaultConverter`1.OnTryRead(Utf8JsonReader& reader, Type typeToConvert, JsonSerializerOptions options, ReadStack& state, T& value)
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)
--- End of inner exception stack trace ---
at System.Text.Json.ThrowHelper.ReThrowWithPath(ReadStack& state, Utf8JsonReader& reader, Exception ex)
at System.Text.Json.Serialization.JsonConverter`1.ReadCore(Utf8JsonReader& reader, JsonSerializerOptions options, ReadStack& state)
at System.Text.Json.Serialization.Metadata.JsonTypeInfo`1.ContinueDeserialize(ReadBufferState& bufferState, JsonReaderState& jsonReaderState, ReadStack& readStack)
at System.Text.Json.Serialization.Metadata.JsonTypeInfo`1.DeserializeAsync(Stream utf8Json, CancellationToken cancellationToken)
at System.Text.Json.Serialization.Metadata.JsonTypeInfo`1.DeserializeAsObjectAsync(Stream utf8Json, CancellationToken cancellationToken)
at ServiceStack.Host.Handlers.ServiceStackHandlerBase.CreateContentTypeRequestAsync(IRequest httpReq, Type requestType, String contentType) in /home/runner/work/ServiceStack/ServiceStack/ServiceStack/src/ServiceStack/Host/Handlers/ServiceStackHandlerBase.cs:line 232
--- End of inner exception stack trace ---
at ServiceStack.Host.Handlers.ServiceStackHandlerBase.CreateContentTypeRequestAsync(IRequest httpReq, Type requestType, String contentType) in /home/runner/work/ServiceStack/ServiceStack/ServiceStack/src/ServiceStack/Host/Handlers/ServiceStackHandlerBase.cs:line 249
at ServiceStack.Host.RestHandler.CreateRequestAsync(IRequest httpReq, IRestPath restPath, Dictionary`2 requestParams) in /home/runner/work/ServiceStack/ServiceStack/ServiceStack/src/ServiceStack/Host/RestHandler.cs:line 156
at ServiceStack.Host.RestHandler.CreateRequestAsync(IRequest httpReq, IRestPath restPath) in /home/runner/work/ServiceStack/ServiceStack/ServiceStack/src/ServiceStack/Host/RestHandler.cs:line 145
at ServiceStack.Host.RestHandler.ProcessRequestAsync(IRequest req, IResponse httpRes, String operationName) in /home/runner/work/ServiceStack/ServiceStack/ServiceStack/src/ServiceStack/Host/RestHandler.cs:line 90
System.Text.Json.JsonException: The JSON value could not be converted to System.Guid. Path: $.Id | LineNumber: 0 | BytePositionInLine: 54.
---> System.FormatException: The JSON value is not in a supported Guid format.
at System.Text.Json.ThrowHelper.ThrowFormatException(DataType dataType)
at System.Text.Json.Utf8JsonReader.GetGuid()
at System.Text.Json.Serialization.Metadata.JsonPropertyInfo`1.ReadJsonAndSetMember(Object obj, ReadStack& state, Utf8JsonReader& reader)
at System.Text.Json.Serialization.Converters.ObjectDefaultConverter`1.OnTryRead(Utf8JsonReader& reader, Type typeToConvert, JsonSerializerOptions options, ReadStack& state, T& value)
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)
--- End of inner exception stack trace ---
at System.Text.Json.ThrowHelper.ReThrowWithPath(ReadStack& state, Utf8JsonReader& reader, Exception ex)
at System.Text.Json.Serialization.JsonConverter`1.ReadCore(Utf8JsonReader& reader, JsonSerializerOptions options, ReadStack& state)
at System.Text.Json.Serialization.Metadata.JsonTypeInfo`1.ContinueDeserialize(ReadBufferState& bufferState, JsonReaderState& jsonReaderState, ReadStack& readStack)
at System.Text.Json.Serialization.Metadata.JsonTypeInfo`1.DeserializeAsync(Stream utf8Json, CancellationToken cancellationToken)
at System.Text.Json.Serialization.Metadata.JsonTypeInfo`1.DeserializeAsObjectAsync(Stream utf8Json, CancellationToken cancellationToken)
at ServiceStack.Host.Handlers.ServiceStackHandlerBase.CreateContentTypeRequestAsync(IRequest httpReq, Type requestType, String contentType) in /home/runner/work/ServiceStack/ServiceStack/ServiceStack/src/ServiceStack/Host/Handlers/ServiceStackHandlerBase.cs:line 232
System.FormatException: The JSON value is not in a supported Guid format.
at System.Text.Json.ThrowHelper.ThrowFormatException(DataType dataType)
at System.Text.Json.Utf8JsonReader.GetGuid()
at System.Text.Json.Serialization.Metadata.JsonPropertyInfo`1.ReadJsonAndSetMember(Object obj, ReadStack& state, Utf8JsonReader& reader)
at System.Text.Json.Serialization.Converters.ObjectDefaultConverter`1.OnTryRead(Utf8JsonReader& reader, Type typeToConvert, JsonSerializerOptions options, ReadStack& state, T& value)
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)
This is how the request looks after calling request.ToJson()
in client:
{
"ProductId" : 1,
"Id" : "eaca59b40b974e4ca6738a304644f96f"
}
Some screenshots from code:
Everything works fine, when I call it from ServiceStack UI:
I tried to add some request filters and JsConfig in AppHost.cs:
JsConfig<Guid>.DeSerializeFn = guid => new Guid(guid);
GlobalRequestFilters.Add((req, res, requestDto) =>
{
});
but neither of these is called when dealing with this request from the client, it seems to fail before entering ServiceStack pipeline. When I call it from ServiceStack UI, both are executed, first DeSerializeFn, then GlobalRequestFilter.
This code is in production on ServiceStack v6, where it seems to work fine.
I am now using ServiceStack 8.5.2 on the API side (.NET 8) and ServiceStack.Client 8.5.2 on desktop (.NET Framework 4.7.2).
I guess I am again missing some configuration in client. Do you have any idea what could help?
Thank you for your response.