I am trying to use StackOverflow's search API to search questions.
I am using this action to perform the parsing :
public ActionResult StackExchange(string sq)
{
string url = "http://api.stackoverflow.com/1.1/search?intitle=" + sq + "&order=desc";
var client = new WebClient();
var response = client.DownloadString(new Uri(url));
JObject o = JObject.Parse(response);// ERROR
int total = (int)o["total"];
return View(total);
}
Here is the JSON url I am trying to parse:
http://api.stackoverflow.com/1.1/search?intitle=asp.net%20custom%20404&order=desc
I am trying to extract the following data:
`"total": 3` ,
`"question_timeline_url": "/questions/10868557/timeline",`
`"title": "Asp.net custom 404 not working using Intelligencia rewriter"`
Its giving error as : Newtonsoft.Json.JsonReaderException: Unexpected character encountered while parsing value: . Path '', line 0, position 0.
What can be the reason for the exception? I used the same method earlier and it worked fine.
Please suggest.