System.Net.Http.Json 9.0.0-preview.1.24080.9

About

Provides extension methods for System.Net.Http.HttpClient and System.Net.Http.HttpContent that facilitate serialization and deserialization of HTTP requests using System.Text.Json.

Key Features

  • Extension methods for deserializing HTTP response JSON bodies.
  • Extension methods for serializing HTTP request JSON bodies.
  • Extension methods for deserializing JSON from HttpContent instances.

How to Use

using System.Net.Http.Json;

using var client = new HttpClient();

// Get the list of all books
Book[] books = await client.GetFromJsonAsync<Book[]>("https://api.contoso.com/books");

// Send a POST request to add a new book
var book = new Book(id: 42, "Title", "Author", publishedYear: 2023);
HttpResponseMessage response = await client.PostAsJsonAsync($"https://api.contoso.com/books/{book.id}", book);

if (response.IsSuccessStatusCode)
    Console.WriteLine("Book added successfully.");
else
    Console.WriteLine($"HTTP request failed with status code: {response.StatusCode}");

public record Book(int id, string title, string author, int publishedYear);

Main Types

The main types provided by this library are:

  • HttpClientJsonExtensions
  • HttpContentJsonExtensions

Additional Documentation

Feedback & Contributing

System.Net.Http.Json is released as open source under the MIT license. Bug reports and contributions are welcome at the GitHub repository.

Showing the top 20 packages that depend on System.Net.Http.Json.

Packages Downloads
Refit
The automatic type-safe REST library for Xamarin and .NET
3
Refit
The automatic type-safe REST library for Xamarin and .NET
4
Refit
The automatic type-safe REST library for Xamarin and .NET
22
Refit
The automatic type-safe REST library for Xamarin and .NET
23
Refit
The automatic type-safe REST library for Xamarin and .NET
24
Refit
The automatic type-safe REST library for Xamarin and .NET
25
Refit
The automatic type-safe REST library for Xamarin and .NET
26
Refit
The automatic type-safe REST library for Xamarin and .NET
27
Refit
The automatic type-safe REST library for Xamarin and .NET
28
Refit
The automatic type-safe REST library for Xamarin and .NET
35

https://go.microsoft.com/fwlink/?LinkID=799421

.NET Framework 4.6.2

.NET 8.0

.NET 9.0

.NET Standard 2.0

Version Downloads Last updated
9.0.0-rc.2.24473.5 1 10/23/2024
9.0.0-rc.1.24431.7 2 09/19/2024
9.0.0-preview.7.24405.7 1 10/23/2024
9.0.0-preview.6.24327.7 4 10/21/2024
9.0.0-preview.5.24306.7 4 09/20/2024
9.0.0-preview.4.24266.19 1 10/21/2024
9.0.0-preview.3.24172.9 1 10/23/2024
9.0.0-preview.2.24128.5 1 10/23/2024
9.0.0-preview.1.24080.9 3 10/23/2024
8.0.1 4 10/21/2024
8.0.0 2 10/21/2024
8.0.0-rc.2.23479.6 3 10/21/2024
8.0.0-rc.1.23419.4 1 10/23/2024
8.0.0-preview.7.23375.6 2 09/20/2024
8.0.0-preview.6.23329.7 1 10/23/2024
8.0.0-preview.5.23280.8 5 09/20/2024
8.0.0-preview.4.23259.5 1 10/23/2024
8.0.0-preview.3.23174.8 2 09/20/2024
8.0.0-preview.2.23128.3 2 09/20/2024
8.0.0-preview.1.23110.8 1 10/23/2024
7.0.1 4 10/21/2024
7.0.0 4 10/21/2024
7.0.0-rc.2.22472.3 3 09/20/2024
7.0.0-rc.1.22426.10 1 10/23/2024
7.0.0-preview.7.22375.6 4 10/21/2024
7.0.0-preview.6.22324.4 1 10/23/2024
7.0.0-preview.5.22301.12 1 10/21/2024
7.0.0-preview.4.22229.4 3 10/23/2024
7.0.0-preview.3.22175.4 1 10/23/2024
7.0.0-preview.2.22152.2 2 09/20/2024
7.0.0-preview.1.22076.8 2 09/20/2024
6.0.1 4 10/21/2024
6.0.0 2 10/21/2024
6.0.0-rc.2.21480.5 4 09/20/2024
6.0.0-rc.1.21451.13 2 10/23/2024
6.0.0-preview.7.21377.19 1 10/21/2024
6.0.0-preview.6.21352.12 3 10/21/2024
6.0.0-preview.5.21301.5 1 10/23/2024
6.0.0-preview.4.21253.7 1 10/23/2024
6.0.0-preview.3.21201.4 1 10/23/2024
6.0.0-preview.2.21154.6 1 10/23/2024
6.0.0-preview.1.21102.12 2 10/21/2024
5.0.0 3 09/20/2024
5.0.0-rc.2.20475.5 2 10/21/2024
5.0.0-rc.1.20451.14 4 10/23/2024
5.0.0-preview.8.20407.11 4 10/21/2024
5.0.0-preview.7.20364.11 1 10/21/2024
5.0.0-preview.6.20305.6 1 10/23/2024
5.0.0-preview.5.20278.1 1 10/23/2024
5.0.0-preview.4.20251.6 1 10/23/2024
5.0.0-preview.3.20214.6 2 09/20/2024
3.2.1 4 10/21/2024
3.2.0 4 10/21/2024
3.2.0-rc1.20217.1 1 10/21/2024
3.2.0-preview5.20210.3 3 10/21/2024
3.2.0-preview3.20175.8 2 09/20/2024