miniwebapi Failed to read parameter "Parameters para" from the request body as JSON #55848
Closed
1 task done
Labels
area-web-frameworks
Needs: Author Feedback
The author of this issue needs to respond in order for us to continue investigating this issue.
Status: No Recent Activity
Is there an existing issue for this?
Is your feature request related to a problem? Please describe the problem.
this is the code :
when i request , the parameter is :
{
"date": ""
}
the important is commany project common webapi allow and not reject advice, the sample parameters is many。
in Controller mod, builder.Services.AddControllers.AddNewtonsoftJson or AddJsonOptions can solve,
the next important is ,if the miniwebapi cut off too many Important function,use mini api meaningless。
this is the result:
Microsoft.AspNetCore.Http.BadHttpRequestException: Failed to read parameter "Parameters para" from the request body as JSON.
---> System.Text.Json.JsonException: The JSON value could not be converted to System.Nullable
1[System.DateTime]. Path: $.date | LineNumber: 1 | BytePositionInLine: 12. ---> System.FormatException: The JSON value is not in a supported DateTime format. at System.Text.Json.ThrowHelper.ThrowFormatException(DataType dataType) at System.Text.Json.Utf8JsonReader.GetDateTime() at System.Text.Json.Serialization.Converters.NullableConverter
1.Read(Utf8JsonReader& reader, Type typeToConvert, JsonSerializerOptions options)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 Microsoft.AspNetCore.Http.HttpRequestJsonExtensions.ReadFromJsonAsync(HttpRequest request, JsonTypeInfo jsonTypeInfo, CancellationToken cancellationToken)
at Microsoft.AspNetCore.Http.HttpRequestJsonExtensions.ReadFromJsonAsync(HttpRequest request, JsonTypeInfo jsonTypeInfo, CancellationToken cancellationToken)
at Microsoft.AspNetCore.Http.RequestDelegateFactory.g__TryReadBodyAsync|102_0(HttpContext httpContext, Type bodyType, String parameterTypeName, String parameterName, Boolean allowEmptyRequestBody, Boolean throwOnBadRequest, JsonTypeInfo jsonTypeInfo)
--- End of inner exception stack trace ---
at Microsoft.AspNetCore.Http.RequestDelegateFactory.Log.InvalidJsonRequestBody(HttpContext httpContext, String parameterTypeName, String parameterName, Exception exception, Boolean shouldThrow)
at Microsoft.AspNetCore.Http.RequestDelegateFactory.g__TryReadBodyAsync|102_0(HttpContext httpContext, Type bodyType, String parameterTypeName, String parameterName, Boolean allowEmptyRequestBody, Boolean throwOnBadRequest, JsonTypeInfo jsonTypeInfo)
at Microsoft.AspNetCore.Http.RequestDelegateFactory.<>c__DisplayClass102_2.<b__2>d.MoveNext()
--- End of stack trace from previous location ---
at Microsoft.AspNetCore.Authorization.AuthorizationMiddleware.Invoke(HttpContext context)
at Swashbuckle.AspNetCore.SwaggerUI.SwaggerUIMiddleware.Invoke(HttpContext httpContext)
at Swashbuckle.AspNetCore.Swagger.SwaggerMiddleware.Invoke(HttpContext httpContext, ISwaggerProvider swaggerProvider)
at Microsoft.AspNetCore.Authentication.AuthenticationMiddleware.Invoke(HttpContext context)
at Microsoft.AspNetCore.Diagnostics.DeveloperExceptionPageMiddlewareImpl.Invoke(HttpContext context)
Describe the solution you'd like
Miniwebapi Add some appropriate extensions
Additional context
The text was updated successfully, but these errors were encountered: