IOS Odata SDK查询选择错误
我已经连接了我的 ipad,因此它现在正在与网络上提供的 OData.svc 进行通信。我可以在没有的情况下对表进行 noraml 查询。但是,一旦我向该查询添加选择以减少正在传输的列,我就会收到 http 400 错误。我可以获得它正在访问的确切网址(http://mywebsite.com/OData.svc/Customers?$top=10&$select=CustomerName)并将其放入浏览器中,它可以正常工作。有什么想法吗?
我在 Netflix 示例中的一个查询中添加了一个选择,它工作得很好,这似乎是我的 OData.svc 不允许从我的 ipad 应用程序中执行选择的问题(但浏览器没问题)。
提前致谢
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
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
$select 要求使用 2.0 版本发送请求。所以它的DataServiceVersion头必须设置为2.0;。如果将其设置为 1.0,则请求将失败并返回 400。您可以使用某种网络跟踪软件查看响应正文来验证这是否是根本原因,该响应正文应包含一条错误消息,说明您想要的功能使用需要更高版本。
它在浏览器上工作,因为浏览器不发送任何版本标头,在这种情况下,服务器假定服务器可以理解的更高版本(因此在这些情况下为 2.0)。
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).