3

I am working on REST call. Everything works fine but my column contains special character &

So rest call like below works:

http://mydomain/_api/web/lists/GetByTitle('MyList')/Items?$filter=ColumnA eq 'DAD'

But below fails:

http://mydomain/_api/web/lists/GetByTitle('MyList')/Items?$filter=ColumnA eq 'D&D'

I dont want to change my column values now. Any solution?

1

3 Answers 3

2

Use something like this:

"http://mydomain/_api/web/lists/GetByTitle('MyList')/Items?$filter=ColumnA eq " + encodeURIComponent("D&D")
2
1

Perhaps try putting the encoded value in directly. Have you tried something like this yet:

"http://mydomain/_api/web/lists/GetByTitle('MyList')/Items?$filter=ColumnA eq 'D%26D'"
0

encodeURIComponent should work. I have been using this method and it always works for me. You have to add D&D in quotes.

Try below URL. Just a little modification from @Gennady G's URL(i.e. quotes are added around the filter value) :

"http://mydomain/_api/web/lists/GetByTitle('MyList')/Items?$filter=Title eq '" + encodeURIComponent("D&D") + "'"

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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