0

Hello I have a API method build in framework 4 which returns string type of data

[HttpPost]
        public string ValidateData(DataTable dt)
        {
            return _repository.ValidateAllData(dt);
        }

Now I want to consume this API method in my asp.net application from server side. Now how do i consume this method with datatable as parameter ?

Mahajan344
  • 2,492
  • 6
  • 39
  • 90

1 Answers1

0
HttpClient cons = new HttpClient();
cons.BaseAddress = new Uri("http://localhost:7967/");
cons.DefaultRequestHeaders.Accept.Clear();
cons.DefaultRequestHeaders.Accept.Add(new System.Net.Http.Headers.MediaTypeWithQualityHeaderValue("application/json"));
HttpResponseMessage res =  await cons.PostAsJsonAsync("api/revise", data);

In above code you need to pass datatable as data parameter to make it working.