Hi team,
Please help me to call my WEB api from win form application.
I am getting error as below. Please suggest me change in my code or new solution i have tried below link solution but not works. -
Could not load file or assembly 'Newtonsoft.Json, Version=4.5.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed' or one of its dependencies. The system cannot find the file specified.
at Line :
HttpResponseMessage response_1 = client.PostAsJsonAsync("/api/AddEmployee/Post", addEmployees_1).Result;
C# win form code
JavaScriptSerializer javaScriptSerializer = new JavaScriptSerializer();
List<AddEmployee> AddEmployee_List = (List<AddEmployee>)javaScriptSerializer.Deserialize(jsonstring, typeof(List<AddEmployee>));
foreach (AddEmployee addEmployees_1 in AddEmployee_List)
{
using (var client = new HttpClient())
{
client.BaseAddress = new Uri("http://localhost:63481/");
HttpResponseMessage response_1 = client.PostAsJsonAsync("/api/AddEmployee/Post", addEmployees_1).Result;
client.DefaultRequestHeaders.Accept.Clear();
client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
if (response_1.IsSuccessStatusCode)
{
label1.Text = "Success";
}
}
}