Question

Ive connected my ipad up so it is now talking to my OData.svc served up on the web. I can do a noraml query of a table without. But as soon as I add a select to that query to cut down the columns being transferred I get a http 400 error. I can get the exact url (http://mywebsite.com/OData.svc/Customers?$top=10&$select=CustomerName) it is accessing and put it into a browser and it works without issue. Any ideas what this could be?

I added a select to one of the queries in the Netflix example and it worked fine, it seems to be something with my OData.svc that isnt allowing selects to be performed from my ipad app (but browser is fine).

Thanks in advance

Was it helpful?

Solution

The $select requires that the request is sent with version 2.0. So its DataServiceVersion header must be set to 2.0;. If it's set to 1.0 the request will fail with 400. You can verify that this is the root cause by using some kind of network tracing software to see the body of the response, which should contain an error message saying that the feature you want to use requires a higher version. It works from the browser, because the browser doesn't send any version header and in that case the server assumes the higher version the server can understand (so 2.0 in these cases).

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top