i'm trying to make some queries to Tridion using OData Webservice. I'm having troubles using filters that contains single quote (') or other charactes like (á,ü,ç,ñ,...).

For example:

http://......./cd_webservice/odata.svc/Keywords?$filter=Description eq 'Gare centrale d'Utrecht'

I tried doubling single quotes, changing single quotes for double quotes, changing single quotes for (%27) character, encoding previously characters using java class URLEncoder and it doesn't work.

I need to know how to escape correctly these characters in Java because every query fails if contains this characters.


The correct way to escape the single quote in OData service url is to update your search text with two single quotes instead of one. You have to manually or through code has to change the search text. eg. 'Gare centrale d''Utrecht'

 http://......./cd_webservice/odata.svc/Keywords?$filter=Description eq 'Gare centrale d''Utrecht'
| improve this answer | |
  • That's also my understanding, but I wonder if he already tried that ("I tried doubling single quotes..."). It's also worth noting that some languages (and therefore keyboard layouts) use different single quotes -- so you will want to make sure you are using the ASCII one. – Peter Kjaer Mar 26 '15 at 13:20
  • hmmm. that annoying ` vs ' – Nuno Linhares Mar 26 '15 at 13:22
  • Hello, im using character ' encoded as char %27 in a URL. I try using two single quotes instead one but does not work. As example i try the request http://......./cd_webservice/odata.svc/Keywords?$filter=Description eq 'Gare centrale d''Utrecht' and the result is: <message xml:lang="en-US">Filter syntax error near value: 'Gare centrale d'</message> – Álex Mar 26 '15 at 14:25

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.