Avatar of Andy Green
Andy GreenFlag for United Kingdom of Great Britain and Northern Ireland asked on

consuming oData in code behind C#


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.


Avatar of undefined
Last Comment
Andy Green

8/22/2022 - Mon
Andy Green

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/>");


Ioannis Paraskevopoulos

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
See how we're fighting big data
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question
Andy Green

Thanks - I was nearly there.

Your help has saved me hundreds of hours of internet surfing.