I am trying to load the data (JSON) from API to SQL Sever Database Table. Able to get the response with Test API but when I am unable to authenticate the API with username and Passport.
{
string connetionString = null;
string sql = null;
string serviceUrl = "https://jsonplaceholder.typicode.com/posts";
HttpClient client = new HttpClient();
client.BaseAddress = new Uri(serviceUrl);
var serializer = new JavaScriptSerializer();
client.DefaultRequestHeaders.Accept.Add(
new MediaTypeWithQualityHeaderValue("application/json"));
connetionString = "Data Source=BM_BHAKST;Initial Catalog=Practice_OPS; Trusted_Connection=True;";
string APIUrl = string.Format(serviceUrl);
var response = client.GetAsync(APIUrl).Result;
if (response.IsSuccessStatusCode)
{
var result = response.Content.ReadAsStringAsync().Result;
var dt = serializer.Deserialize<Dictionary<string,string>[]>(result);
using (SqlConnection cnn = new SqlConnection(connetionString))
//using (SqlConnection cnn = new SqlConnection(connetionString))
//DataTable dataTable = new DataTable();
//SqlConnection cnn = new SqlConnection(connetionString);
{
I am completely new to c# can anyone help me to implement the same functionality with username & password. (Username : BASIC_Reporting ,Password : Abc12345)