Skip to content

AddNewtonsoftJson and ProblemDetails using NET 6 #200

Description

@wzaieddev

Hi,
I still having the same problem as (#74 )

I'am having problems using Newtonsoft as the json serializer with problem details.
When this package returns the problem details the Extensions property is serialzied as "Extensions": {...} and not to the parent.

My Web API is built withNET 6
i'm using Hellang.Middleware.ProblemDetails vs 6.5.1

example of response
{
"error": {
"code": "xxxxxxx",
"message": "TEST EXCEPTION"
},
"type": "https://httpstatuses.io/422",
"title": "Bad Request",
"status": 422,
"detail": null,
"instance": "/api/v2/",
"extensions": {
"traceId": "00-c7eeff3ccf1f649acb783983201da96d-b6eab3d064ab8984-00",
"timestamp": "2023-09-21T20:14:36.2960678+02:00"
}
}
when I JSON serializer xx the problem does not arise, and the response is like this

{
"error": {
"code": "xxxxxxx",
"message": "TEST EXCEPTION"
},
"type": "https://httpstatuses.io/422",
"title": "Bad Request",
"status": 422,
"detail": null,
"instance": "/api/v2/",
"traceId": "00-c7eeff3ccf1f649acb783983201da96d-b6eab3d064ab8984-00",
"timestamp": "2023-09-21T20:14:36.2960678+02:00"

}

is there any solution to keep using Newtonsoft ?

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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