You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: aspnetcore/blazor/call-web-api.md
+55Lines changed: 55 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -676,6 +676,35 @@ Laid out with indentation, spacing, and unescaped quotes, the unencoded PATCH do
676
676
677
677
To simplify the creation of PATCH documents in the app issuing PATCH requests, an app can use .NET JSON PATCH support, as the following guidance demonstrates.
678
678
679
+
:::moniker-end
680
+
681
+
:::moniker range=">= aspnetcore-10.0"
682
+
683
+
<!-- UPDATE 10.0 - API doc cross-link -->
684
+
685
+
Install the [`Microsoft.AspNetCore.JsonPatch.SystemTextJson`](https://www.nuget.org/packages/Microsoft.AspNetCore.JsonPatch.SystemTextJson) NuGet package and use the API features of the package to compose a `JsonPatchDocument` for a PATCH request.
686
+
687
+
[!INCLUDE[](~/includes/package-reference.md)]
688
+
689
+
Add `@using` directives for the <xref:System.Text.Json?displayProperty=fullName>, <xref:System.Text.Json.Serialization?displayProperty=fullName>, and `Microsoft.AspNetCore.JsonPatch.SystemTextJson`<!-- <xref:Microsoft.AspNetCore.JsonPatch.SystemTextJson?displayProperty=fullName> --> namespaces to the top of the Razor component:
Install the [`Microsoft.AspNetCore.JsonPatch`](https://www.nuget.org/packages/Microsoft.AspNetCore.JsonPatch) NuGet package and use the API features of the package to compose a <xref:Microsoft.AspNetCore.JsonPatch.JsonPatchDocument> for a PATCH request.
680
709
681
710
[!INCLUDE[](~/includes/package-reference.md)]
@@ -695,6 +724,10 @@ var patchDocument = new JsonPatchDocument<TodoItem>()
695
724
.Replace(p=>p.IsComplete, true);
696
725
```
697
726
727
+
:::moniker-end
728
+
729
+
:::moniker range=">= aspnetcore-7.0"
730
+
698
731
Pass the document's operations (`patchDocument.Operations`) to the <xref:System.Net.Http.Json.HttpClientJsonExtensions.PatchAsJsonAsync%2A> call:
Follow the guidance in the <xref:web-api/jsonpatch> article to add a PATCH controller action to the web API. Alternatively, PATCH request processing can be implemented as a [Minimal API](xref:fundamentals/minimal-apis) with the following steps.
718
751
752
+
:::moniker-end
753
+
754
+
:::moniker range=">= aspnetcore-10.0"
755
+
756
+
<!-- UPDATE 10.0 - API doc cross-link -->
757
+
758
+
Add a package reference for the [`Microsoft.AspNetCore.JsonPatch.SystemTextJson`](https://www.nuget.org/packages/Microsoft.AspNetCore.Mvc.NewtonsoftJson) NuGet package to the web API app.
759
+
760
+
In the `Program` file add an `@using` directive for the `Microsoft.AspNetCore.JsonPatch.SystemTextJson`<!-- <xref:Microsoft.AspNetCore.JsonPatch.SystemTextJson?displayProperty=fullName> --> namespace:
Add a package reference for the [`Microsoft.AspNetCore.Mvc.NewtonsoftJson`](https://www.nuget.org/packages/Microsoft.AspNetCore.Mvc.NewtonsoftJson) NuGet package to the web API app.
720
771
721
772
> [!NOTE]
@@ -727,6 +778,10 @@ In the `Program` file add an `@using` directive for the <xref:Microsoft.AspNetCo
727
778
usingMicrosoft.AspNetCore.JsonPatch;
728
779
```
729
780
781
+
:::moniker-end
782
+
783
+
:::moniker range=">= aspnetcore-7.0"
784
+
730
785
Provide the endpoint to the request processing pipeline of the web API:
0 commit comments