Link to home
Start Free TrialLog in
Avatar of Andy Green
Andy GreenFlag for United Kingdom of Great Britain and Northern Ireland

asked on

consuming oData in code behind C#

Hi

Is it possible to get the data returned by an oData feed into the code behind for server side binding. I cant even add my oData feed as a service reference, but that might be a separate issue.

I'm looking for examples I can pick apart., been all over google but nothing helpful so far.

I have already looked here, https://msdn.microsoft.com/en-us/data/gg591296  but the service isn't working so I cant test it. Also some feeds from oData.org cant be added as sercives references.

Andy
Avatar of Andy Green
Andy Green
Flag of United Kingdom of Great Britain and Northern Ireland image

ASKER

I now have this, so I can get JSON on the r server, how do I parse it so I can dind to a data control?

            HttpWebRequest WebReq = (HttpWebRequest)WebRequest.Create(string.Format("http://Localhost/odata/locations?$expand=Children($expand=Children)"));
            WebReq.Method = "GET";
            WebReq.ContentType = "application/JSON";
            HttpWebResponse WebResp = (HttpWebResponse)WebReq.GetResponse();

            Stream Answer = WebResp.GetResponseStream();
            StreamReader _Answer = new StreamReader(Answer);

            Response.Write(WebResp.StatusCode + "<br/>");
            Response.Write(_Answer.ReadToEnd());

            WebResp.Close();

Andy
ASKER CERTIFIED SOLUTION
Avatar of Ioannis Paraskevopoulos
Ioannis Paraskevopoulos
Flag of Greece image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Thanks - I was nearly there.

Andy