' Odata Url 字符串参数中的字符
嗯,这看起来很傻,所以我觉得很傻。我在 Odata 服务上有一个自定义操作,它有一个字符串参数。当字符串不包含特殊字符时它工作正常,但是一旦我包含 ['] 字符,我就会得到:
<?xml version=\"1.0\" encoding=\"utf-8\" standalone=\"yes\"?>\r\n<error xmlns=\"http://schemas.microsoft.com/ado/2007/08/dataservices/metadata\">\r\n <code></code>\r\n <message xml:lang=\"en-US\">Bad Request - Error in query syntax.</message>\r\n</error>
我正在使用以下代码调用服务:
new DataServiceContext(new Uri(svcUri)).Execute<string>(new Uri(relativeOperationUrl, UriKind.Relative));
我尝试过像这样的编码 [& apos;](xml 编码)和像这样的 [%27](url 编码),事情仍然在爆炸。
Hmmm this seems silly, so I feel silly. I have a custom operation on an Odata service which has a string parameter. It works fine when the string contains no special characters, but as soon as I include the ['] character I get:
<?xml version=\"1.0\" encoding=\"utf-8\" standalone=\"yes\"?>\r\n<error xmlns=\"http://schemas.microsoft.com/ado/2007/08/dataservices/metadata\">\r\n <code></code>\r\n <message xml:lang=\"en-US\">Bad Request - Error in query syntax.</message>\r\n</error>
I am invoking the service with the following code:
new DataServiceContext(new Uri(svcUri)).Execute<string>(new Uri(relativeOperationUrl, UriKind.Relative));
I've tried encoding like this [& apos;] (xml encoding) and like this [%27] (url encoding) and the things is still blowing up.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
尝试
''
(就像在 SQL 中转义它一样);请参阅如何转义单个OData 查询中要使用的报价?。Try
''
(like escaping it for SQL); see How to escape a single quote to be used in an OData query?.