Hi All,
In my application, we would like to extract the data from FB API for 50 companies and below is my code
try
{
DataTable dt = GetCompanySocialMediaFBLinks();
for (int i = 0; i < rowsCount; i++)
{
string absoluteUri2 = dt.Rows[i]["FBLink"].ToString();
if (absoluteUri2 != "")
{
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(absoluteUri2);
var response = (HttpWebResponse)request.GetResponse();
var reader = new StreamReader(response.GetResponseStream());
var objJSONResp = reader.ReadToEnd();
if (objJSONResp != null)
{
JavaScriptSerializer json_serializer = new JavaScriptSerializer();
Facebook fbData = json_serializer.Deserialize<Facebook>(objJSONResp);
_noOfLikes = fbData.likes;
}
}
}
}
catch (Exception exception)
{
System.Console.ForegroundColor = ConsoleColor.Yellow;
System.Console.WriteLine(exception.InnerException);
continue;
}
when we run this code, we are getting "the remote server returned an error 400 bad request" at line # 7 in above code becasue some of the requests are returning Unsupported get request from FB server. How to control these errors and run the loop continuosly. When this error comes, the for loop is stopped. we want to conntinue the loop 50 times even if the exception comes. can anyone help me on this ?