I am trying to call a web API from my web application. I am using .Net 4.5 and while writing the code I am getting the error HttpClient
does not contain a defin
Instead of writing this amount of code to make a simple call, you could use one of the wrappers available over the internet.
I've written one called WebApiClient, available at NuGet... check it out!
https://www.nuget.org/packages/WebApiRestService.WebApiClient/
If you're playing around in Blazor and get the error, you need to add the package Microsoft.AspNetCore.Blazor.HttpClient
.
I know this reply is too late, I had the same issue and i was adding the System.Net.Http.Formatting.Extension
Nuget, after checking here and there I found that the Nuget is added but the System.Net.Http.Formatting.dll
was not added to the references, I just reinstalled the Nuget
The missing reference is the System.Net.Http.Formatting.dll
. But the better solution is to add the NuGet package Microsoft.AspNet.WebApi.Client
to ensure the version of the formatting dll worked with the .NET framework version of System.Net.Http
in my project.
Ok, it is apocalyptical 2020 now, and you can find these methods in NuGet package System.Net.Http.Json
. But beware that it uses System.Text.Json
internally.
And if you really need to find out which API resides where, just use https://apisof.net/
Try to install in your project the NuGet Package: Microsoft.AspNet.WebApi.Client:
Install-Package Microsoft.AspNet.WebApi.Client