I'm building an ASP.NET MVC 5 razor application that calls a RESTful API web service.. One of the calls in the API uses a POST method. I have this line in my code:
var response = httpClient.PostAsJsonAsync("/api/account/AddUserAccount", item).Result;
Now, I was able to build that line without any errors displaying, but when I build the application, I get
'HttpClient' does not contain a definition for 'PostAsJsonAsync' and no extension method 'PostAsJsonAsync' accepting a first argument of type 'HttpClient' could be found
I've done a search on the error and I've found posts on Stack Overflow that say to add a reference to System.Net.Http.Formatting.dll, but I can't find that DLL on my system. How do I fix this error?
var response = await client.PostAsync("api/values", new StringContent(Newtonsoft.Json.JsonConvert.SerializeObject(item);, Encoding.UTF8,"application/json"));
– MaKCbIMKo