Osama Bin Gandhi Posted July 8, 2014 Report Posted July 8, 2014 I'm consuming someones webservices using POST method.total 3 functions call cheyyali 1) Enceryption key 2) Session ID 3) GetDATA mooditiki same post function use chestunna (ofcourse different Url's). GetData matuku returning HTML...ekkada issue oo kaastha cheppandi(my side or server side) here is my code: Uri url = new Uri("http://google.com/RestAuth"); HttpWebRequest requestSent = HttpWebRequest.Create(url) as HttpWebRequest; requestSent.Method = "POST"; requestSent.ContentType = "application/x-www-form-urlencoded"; //application/json kooda tried var postData = Encoding.UTF8.GetBytes(strRequest.Trim()); requestSent.ContentLength = postData.Length; using (var requestStream = requestSent.GetRequestStream()) { requestStream.Write(postData, 0, postData.Length); } responseStream = new StreamReader(response.GetResponseStream()); string info = responseStream.ReadToEnd().ToString(); ( is returning HTML instead of JSON) dynamic stuff = JObject.Parse(responseStream.ReadToEnd());
puli_keka Posted July 8, 2014 Report Posted July 8, 2014 I'm consuming someones webservices using POST method.total 3 functions call cheyyali 1) Enceryption key 2) Session ID 3) GetDATA mooditiki same post function use chestunna (ofcourse different Url's). GetData matuku returning HTML...ekkada issue oo kaastha cheppandi(my side or server side) here is my code: Uri url = new Uri("http://google.com/RestAuth"); HttpWebRequest requestSent = HttpWebRequest.Create(url) as HttpWebRequest; requestSent.Method = "POST"; requestSent.ContentType = "application/x-www-form-urlencoded"; //application/json kooda tried var postData = Encoding.UTF8.GetBytes(strRequest.Trim()); requestSent.ContentLength = postData.Length; using (var requestStream = requestSent.GetRequestStream()) { requestStream.Write(postData, 0, postData.Length); } responseStream = new StreamReader(response.GetResponseStream()); string info = responseStream.ReadToEnd().ToString(); ( is returning HTML instead of JSON) dynamic stuff = JObject.Parse(responseStream.ReadToEnd()); seems like an unhandled exception thrown by the IIS server.. nee code varaku baane undi.. debug chesi aa HTML error chudu.. does GetData need any headers like authorization or do you need to pass any API key?
MegaPowerRockstar Posted July 8, 2014 Report Posted July 8, 2014 Also look for namespaces, if need to pass.. Naku namespaces tho issue vachindhe while testing my API svc
puli_keka Posted July 8, 2014 Report Posted July 8, 2014 and also install fiddler tool if you are not already using any other HTTP traffic analyzer .. and check what is the request headers and response headers.. 1
Recommended Posts