Hi
I have below code & i want to save it in Sql Database
protected void MyOwnVideos()
{
StringBuilder htmlTable = new StringBuilder();
var client = new RestClient("googleapis.com/youtube/v3");
var request = new RestRequest("search", Method.GET);
request.AddParameter("part", "snippet");
request.AddParameter("type", "video");
request.AddParameter("channelId", "UC_nNoaVw"); // Replace with your actual channelId
request.AddParameter("key", "AIz8..."); // Replace with your actual API key
IRestResponse<YoutubeSearchListResponse> response = client.Execute<YoutubeSearchListResponse>(request);
// Check if the response contains data
if (response.Data == null || response.Data.items == null || response.Data.items.Count == 0)
{
Console.WriteLine("No Data Found. Please check your channelId and API key.");
return;
}
// Build the HTML table
htmlTable.Append("<table class='table table-bordered table-hover datatable-highlight' id='tbldata'>");
htmlTable.Append("<thead><tr><th>Video Id</th><th>Video Title</th><th>Description</th><th>Published</th></tr></thead>");
htmlTable.Append("<tbody>");
foreach (var data in response.Data.items.OrderBy(x => x.snippet.publishedAt))
{
htmlTable.Append("<tr>");
htmlTable.Append($"<td>{data.id}</td>");
htmlTable.Append($"<td>{data.snippet.title}</td>");
htmlTable.Append($"<td>{data.snippet.description}</td>");
htmlTable.Append($"<td>{data.snippet.publishedAt}</td>");
htmlTable.Append("</tr>");
}
htmlTable.Append("</tbody>");
htmlTable.Append("</table>");
// Output the HTML table
Console.WriteLine(htmlTable.ToString());
}
Thanks