-1

I am new to api, i want to ask how to use console app to store api data into sql server database? I have use console app to call api data successfully already, but how can i use console application to insert api data into sql server database table. my web api came from iis server.

Here is the code for call api data:

using (var client = new WebClient())
            {
                client.Headers.Add("Content-Type:application/xml");
                client.Headers.Add("Accept:application/xml");
                var result = client.DownloadString("http://localhost/test/api/person");
                Console.WriteLine(Environment.NewLine + result);
            }
            MessageBox.Show("Completed");
        }
Progman
  • 16,827
  • 6
  • 33
  • 48
user19928919
  • 67
  • 1
  • 6

1 Answers1

1

If you have successfully fetched data from Api, you can then convert that data into C# Object using newtonsoft deserialize method and use SqlAdapter for inserting that data into a sql Database.

Look into the below attached link for inserting data in db using sqlAdapter.

Using SqlDataAdapter to insert a row