System.Net.Http.Json 9.0.0

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
43
Refit
The automatic type-safe REST library for Xamarin and .NET
21
Refit
The automatic type-safe REST library for Xamarin and .NET
13
Refit
The automatic type-safe REST library for Xamarin and .NET
12
Refit
The automatic type-safe REST library for Xamarin and .NET
11
Refit
The automatic type-safe REST library for Xamarin and .NET
6
Refit
The automatic type-safe REST library for Xamarin and .NET
5
Refit
The automatic type-safe REST library for Xamarin and .NET
4
Refit
The automatic type-safe REST library for Xamarin and .NET
3
Refit
The automatic type-safe REST library for Xamarin and .NET
2
Docker.DotNet.Enhanced
Docker.DotNet is a library that allows you to interact with the Docker Remote API programmatically with fully asynchronous, non-blocking and object-oriented code in your .NET applications.
2
Refit
The automatic type-safe REST library for Xamarin and .NET
1

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

.NET Framework 4.6.2

.NET 8.0

.NET 9.0

  • No dependencies.

.NET Standard 2.0

Version Downloads Last updated
9.0.0 1 11/19/2024
9.0.0-rc.2.24473.5 1 10/09/2024
9.0.0-rc.1.24431.7 6 09/16/2024
9.0.0-preview.7.24405.7 3 08/14/2024
9.0.0-preview.6.24327.7 4 07/13/2024
9.0.0-preview.5.24306.7 24 06/12/2024
9.0.0-preview.4.24266.19 4 05/23/2024
9.0.0-preview.3.24172.9 12 04/12/2024
9.0.0-preview.2.24128.5 11 03/13/2024
9.0.0-preview.1.24080.9 5 02/14/2024
8.0.1 6 10/09/2024
8.0.0 5 02/13/2024
8.0.0-rc.2.23479.6 4 02/14/2024
8.0.0-rc.1.23419.4 17 11/07/2023
8.0.0-preview.7.23375.6 14 02/10/2024
8.0.0-preview.6.23329.7 4 02/13/2024
8.0.0-preview.5.23280.8 4 02/13/2024
8.0.0-preview.4.23259.5 10 11/15/2023
8.0.0-preview.3.23174.8 33 07/13/2023
8.0.0-preview.2.23128.3 13 05/31/2023
8.0.0-preview.1.23110.8 14 02/13/2024
7.0.1 28 07/13/2023
7.0.0 5 02/13/2024
7.0.0-rc.2.22472.3 2 02/13/2024
7.0.0-rc.1.22426.10 29 09/12/2023
7.0.0-preview.7.22375.6 13 12/06/2023
7.0.0-preview.6.22324.4 4 02/13/2024
7.0.0-preview.5.22301.12 17 05/27/2023
7.0.0-preview.4.22229.4 21 06/02/2023
7.0.0-preview.3.22175.4 7 02/13/2024
7.0.0-preview.2.22152.2 18 02/13/2024
7.0.0-preview.1.22076.8 12 02/13/2024
6.0.2 1 11/19/2024
6.0.2-mauipre.1.22102.15 11 12/05/2023
6.0.2-mauipre.1.22054.8 4 02/13/2024
6.0.1 10 10/14/2023
6.0.0 25 08/11/2023
6.0.0-rc.2.21480.5 4 02/14/2024
6.0.0-rc.1.21451.13 11 02/13/2024
6.0.0-preview.7.21377.19 19 10/20/2023
6.0.0-preview.6.21352.12 4 02/19/2024
6.0.0-preview.5.21301.5 16 08/01/2023
6.0.0-preview.4.21253.7 28 05/18/2023
6.0.0-preview.3.21201.4 5 02/14/2024
6.0.0-preview.2.21154.6 19 05/14/2023
6.0.0-preview.1.21102.12 18 09/13/2023
5.0.0 24 10/28/2023
5.0.0-rc.2.20475.5 27 05/20/2023
5.0.0-rc.1.20451.14 15 10/04/2023
5.0.0-preview.8.20407.11 6 02/19/2024
5.0.0-preview.7.20364.11 14 02/15/2024
5.0.0-preview.6.20305.6 6 02/13/2024
5.0.0-preview.5.20278.1 9 02/13/2024
5.0.0-preview.4.20251.6 35 07/12/2023
5.0.0-preview.3.20214.6 7 02/14/2024
3.2.1 28 05/06/2023
3.2.0 3 02/13/2024
3.2.0-rc1.20217.1 6 02/13/2024
3.2.0-preview5.20210.3 20 08/19/2023
3.2.0-preview3.20175.8 3 02/13/2024