Hello All,
I am consuming a rest service and getting JSON response. After receiving response , I am loading it as below-
HttpWebRequest httpWebRequest = (HttpWebRequest)WebRequest.Create(URL);
httpWebRequest.Method = "GET";
httpWebRequest.Headers.Add("Authorization", token);
HttpWebResponse response = (HttpWebResponse)httpWebRequest.GetResponse();
using (StreamReader sr = new StreamReader(response.GetResponseStream()))
{
var jsonResponse = sr.ReadToEnd().ToString();
XmlDocument xmlDoc = new XmlDocument();
xmlDoc.LoadXml(jsonResponse);
}
Same code was working fine since last 4 month but suddenly its stopped working after adding one new field in the JSON response and giving the below error message -
Data at the root level is invalid. Line 1, position 1.
I have checked the JSON response but could not find any unusual thing.
Sample Json response what we are getting right now-
{"timeCreated":"2015-12-03T06:15:24Z","returnCode":200,"message":"OK","numofrecords":5097,"Item":[{"a":{"name":"XYZ","p":1111111,"q":2222222,"r":"ABCD2","A":3,"B":89,"C":7,"D":7,"length":92.0,"width":14.0,"type":"sssss","updateTime":"2015-08-13T08:32:38Z"},"qaz":{"updateTime":"2015-12-03T06:11:44Z","datetime":"2015-12-04T06:00:00Z","desk":"LANKA","ht":4.2,"ce":"A-AID"},"tion":{"timeReceived":"2015-12-03T06:13:38Z","src":"A-AID","lanofsan":-0.08444166666666666,"latta":49.836416666666665,"songness":10.9,"congress":47.8,"hdngness":51.0,"rottted":0,"atatus":0},"PQRST":{"nation":"LANKA","code":"KMHYR","Country":"India"},"CFTRE":{"timeOfange":"2015-12-02T21:27:30Z","firststatus":"fast"}}]}
Please help me to get the root cause why its working fine previously and now its not working.
Thanks,
NK