I have a AspNetCore-WebApi-Project with several patch-operations, which worked fine with Core 2.2. After migration to Core 3 the [FromBody] JsonPatchDocument<T>
is null. My Get/Post-Methods are still functioning as expected.
This is one part of my Startup:
services.AddDbContext<MyContext>(options => options
.UseLazyLoadingProxies()
.UseNpgsql(Configuration.GetConnectionString("MyConnectionString"),
opt => opt.UseNodaTime()));
services.AddSwaggerGen(c =>
{
c.SwaggerDoc("v1", new OpenApiInfo { Title = "My-API", Version = "v1" });
});
services.AddControllers()
.AddNewtonsoftJson();
This is my Action:
[HttpPatch("{id}")]
public async Task<IActionResult> Patch(Guid id,
[FromBody] JsonPatchDocument<MyViewModel> patchDocument)
{
await this.service.HandlePatchAsync(id, patchDocument);
return NoContent();
}
This is the body-content:
[
{
"op": "replace",
"path": "/name",
"value": "New Name"
},
{
"op": "replace",
"path": "/country",
"value": "Germany"
}
]
Does anyone have an idea what is goung wrong here?