1

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.

Jonathon Kresner
  • 2,793
  • 5
  • 29
  • 40

1 Answers1

2

Try '' (like escaping it for SQL); see How to escape a single quote to be used in an OData query?.

Community
  • 1
  • 1
Jeremiah Willcock
  • 30,161
  • 7
  • 76
  • 78