prasanna p

prasanna p

  • 1.7k
  • 298
  • 26.7k

how to insert Html content from Web API to a Datatable

Sep 22 2020 10:23 AM
Hi friends,
 
I am getting the following response from  the Web API.
 
"Name","Invoice Number","Invoice Date","Amount","Tax","Total Amount","Transaction Type"
"user","1000108","2020-02-20 16:46:36","16696.00","500.00","17196.00","SALE"
"user1","1000109","2020-02-22 16:28:58","6767.00","202.00","6969.00","SALE"
 
It is not in the  json format.I am splitting content with the commas like this
var content = response.Content.ReadAsStringAsync().Result;
List<string> obj = content.Split(',').ToList<string>();
 
in the list it is not getting the name and value simply it is showing indivitual values.
I checked with the 
DataTable obj = JsonConvert.DeserializeObject<DataTable>(content);
List<Dictionary<string, string>> obj = Newtonsoft.Json.JsonConvert.DeserializeObject<List<Dictionary<string, string>>>(content);
 
but getting conversion error
 
Please tell me how to insert the values into the data table. 
 

Brought to you by:

Answers (2)