Here I will explain how to download JSON string from page url and how to set User-Agent in header.
Also Convert JSON string into Datatable.
string str = "type your json url here";
Also Convert JSON string into Datatable.
string str = "type your json url here";
WebClient webClient = new WebClient(); if (webClient == null) { webClient = new WebClient(); } else { webClient.Dispose(); webClient = null; webClient = new WebClient(); } DataTable JsonDataTable = new DataTable(); //Set Header webClient.Headers["User-Agent"] = "Mozilla/4.0 (Compatible; Windows NT 5.1; MSIE 6.0) (compatible; MSIE 6.0; Windows NT 5.1; .NET CLR 1.1.4322; .NET CLR 2.0.50727)"; //Download Content string JsonSting = webClient.DownloadString(str); //Convert JSON to Datatable JsonDataTable = (DataTable)JsonConvert.DeserializeObject(JsonSting, (typeof(DataTable))); JsonDataTable.TableName = "JSON_MAST";
Comments
Post a Comment