Skip to Content

​Service Layer: How To Filter Results By Single Quote?

Nov 16, 2017 at 06:25 PM


avatar image


I’m currently using the filter method on CardName in Service Layer. I want to know how would I do a text search with single quote? For example, William's. Searching online, I heard some people use double single quotes to make it to work in oData. Below is the sample query I quoted in Service Layer. However, it will not return any results. I think because the single quote after the letter m, Service Layer might be thinking this is the end of my filter for CardName. Can you advise a way I can make a query like this to work that contains a single quote?

https://~~~~:50000/b1s/v1/BusinessPartners?$filter=CardName eq 'William''s'



10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

2 Answers

Best Answer
William Grant Nov 28, 2017 at 06:48 PM

I made a support ticket with SAP about this issue. Appearnetly it a bug and they will fix it in 9.2 PL10.

10 |10000 characters needed characters left characters exceeded
Sergio Guerrero Nov 16, 2017 at 06:47 PM

you have to encode the single quote...


...=CardName eq 'William's' (replace ' (no spaces -->) & a p o s


...=CardName eq 'William%27s' -- (no spaces -->) % 27

Show 3 Share
10 |10000 characters needed characters left characters exceeded

Hi Sergio,

I did use %27 before I wrote this post but this does not work either. When I test in Postman, I get reply back

"Query string error - no matched single quote is found"

I did read a Stack Over Flow post

How to escape a single quote to be used in an OData query?

Many people wrote in that post %27 does not work


...=CardName eq 'William''s' ---> 2 single quotes between m and s.... they will get changed to 2-%27 by the browser and will return your output


Hi Sergio,

Double quotes after the m does not work either. Service Layer is assuming seeing the first quote after the m is the end of my search.