I tried to escape the single quote when preparing the query in JS this way:
_value.replace(/'/g,'%27')
and this way:
_value.replace(/\'/g,'\\\'');
both doesn't seem to work
You can see an example here: .svc/Orders?$select=Freight,CustomerID&$filter=ShipName+eq+'B's%20Beverages'&$format=json
Does anyone know how to escape the single quote?
Thanks
I tried to escape the single quote when preparing the query in JS this way:
_value.replace(/'/g,'%27')
and this way:
_value.replace(/\'/g,'\\\'');
both doesn't seem to work
You can see an example here: http://services.odata.org/V3/Northwind/Northwind.svc/Orders?$select=Freight,CustomerID&$filter=ShipName+eq+'B's%20Beverages'&$format=json
Does anyone know how to escape the single quote?
Thanks
Share Improve this question asked Oct 11, 2013 at 13:17 Mohamed Ali JAMAOUIMohamed Ali JAMAOUI 14.7k14 gold badges78 silver badges123 bronze badges3 Answers
Reset to default 15The single quote need to be doubled, for instance:
ShipName+eq+'B''sBeverages'
instead of
ShipName+eq+'B'sBeverages'
Used this code to replace single quote... Its working..
_value.replace(/'/g, '%27%27')
as per example 3 of http://docs.oasis-open.org/odata/odata/v4.01/cs01/part2-url-conventions/odata-v4.01-cs01-part2-url-conventions.html#sec_URLComponents
you need escape a quote with a quote (also, don't forget to handle & : encode to %26 )
so "bit's & bobs" becomes "bit''s %26 bobs"