How to avoid single quote in odata filter uri?

I tried to avoid a single quote when preparing a request in JS as follows:

_value.replace(/'/g,'%27') 

and as follows:

 _value.replace(/\'/g,'\\\''); 

both do not work

Here you can see an example: 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 avoid a single quote?

thanks

+6
source share
2 answers

a single quote should be doubled, for example:

 ShipName+eq+'B''sBeverages' 

instead

 ShipName+eq+'B'sBeverages' 
+10
source

This code is used to replace a single quote ... Its working.

 _value.replace(/'/g, '%27%27') 
0
source

Source: https://habr.com/ru/post/955769/


All Articles