Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to escape single quote in odata filter uri?

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

like image 378
Mohamed Ali JAMAOUI Avatar asked Oct 11 '13 13:10

Mohamed Ali JAMAOUI


Video Answer


1 Answers

The single quote need to be doubled, for instance:

ShipName+eq+'B''sBeverages'

instead of

ShipName+eq+'B'sBeverages'
like image 151
Mohamed Ali JAMAOUI Avatar answered Sep 28 '22 20:09

Mohamed Ali JAMAOUI