From 64beeb3934fbdc04d565ab03ac9e1dc06ae7e34d Mon Sep 17 00:00:00 2001 From: gbarrs-at-em <57711667+gbarrs-at-em@users.noreply.github.com> Date: Fri, 11 Jun 2021 20:59:07 +0100 Subject: [PATCH] Update jsonpatch.md It took me longer than I care to admit before I worked out I was getting a 400 response to a Patch request because I was serialising the request using `JsonSerializer.Serialize` rather than `JsonConvert.SerializeObject`. --- aspnetcore/web-api/jsonpatch.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/aspnetcore/web-api/jsonpatch.md b/aspnetcore/web-api/jsonpatch.md index 57e33418d8..27a8e16192 100644 --- a/aspnetcore/web-api/jsonpatch.md +++ b/aspnetcore/web-api/jsonpatch.md @@ -46,6 +46,8 @@ The preceding code requires the `Microsoft.AspNetCore.Mvc.NewtonsoftJson` packag [!code-csharp[](jsonpatch/samples/3.0/WebApp1/Startup.cs?name=snippet1)] +Use the `Newtonsoft.Json.JsonConvert.SerializeObject` method to serialize a JsonPatchDocument. + ## PATCH HTTP request method The PUT and [PATCH](https://tools.ietf.org/html/rfc5789) methods are used to update an existing resource. The difference between them is that PUT replaces the entire resource, while PATCH specifies only the changes.