HttpClient' does not contain a definition for 'PostAsJsonAsync' and no accessible extension method 'PostAsJsonAsync' accepting a first argument of type 'HttpClient' could be found (are you missing a using directive or an assembly reference?) code example

Example 1: postasjsonasync not found

Yes, you need to add a reference to

System.Net.Http.Formatting.dll
This can be found in the extensions assemblies area.

A good way of achieving this is by adding the NuGet package Microsoft.AspNet.WebApi.Client to your project.

Example 2: postasjsonasync reference c#

Install [NuGet package] Microsoft.AspNet.WebApi.Client & System.Net.Http.Formatting.Extension