JsonPatchDocument problems with Minimal API in .NET6 / 7 parameter Json problems

202 Views Asked by At

Struggling to get MapPatch to work with minimal API and JsonPatchDocument. The result when passing in a valid json PATCH object is always

'Failed to read parameter "JsonPatchDocument patchDocument" from the request body as JSON'

and

'The JSON value could not be converted to Microsoft.AspNetCore.JsonPatch.JsonPatchDocument'.

Have read many articles on this with no luck.

Method has as a parameter

app.MapPatch("/*****/{id}", async ([FromServices] IMediator mediator, string id, [FromBody] JsonPatchDocument patchDocument) =>

and the body being passed in is:

[ { "path": "name", "op": "replace", "value": "string" } ]

The works in Web API but not minimal API. Maybe something simple?

0

There are 0 best solutions below