Tuesday, December 9, 2014

Handling special characters in the REST services are very important part of REST programming.

You will encounter issues if you use them and don't handle properly. I have faced this issue when user was trying to filter list data on this basis of text. Whenever user put special characters REST service throws error. Then I spent a day to find out the answer to this issue and which is very simple. J

So what is the solution to avoid this issue? It is simple, before  sending the filter text convert it to Unicode using 'encodeURIComponent' method. This method encodes the special characters which may create problem while call.

The special character single quote: ‘ needs extra attention, so whenever your filter text contains single quote: ' replace it with two single quotes like: ''. Remember this is not double quoteJ. So in this way you can overcome the special characters problem in REST services.

Happy SharePoint coding.


Post a Comment