Recently, a question came up in the Project Server User Forums, where the user was trying to use a value as a filter in an OData query. The challenge was that the value he was filtering for, had an ‘&’ (ampersand) in it. So, the query was generating errors, explained below.

In this example, I am trying to filter for projects that have the field ‘Client’ equals ‘AT&T’. So, I would write the query as,

https://sgsglobal.sharepoint.com/sites/pwa2/_api/ProjectData/Projects/?$filter=Name eq ‘AT&T’

This would yield a result like this:

image

This is because ‘&’ is a special character that has special meaning when used in a URL Query.
If you are old timer with SQL or have development background, you may know how to handle these. But if you are new to OData like me, you need to know that some of the special characters cannot be used in a URL query, and need to encoded.

So, long story short, you have to encode ‘&’ as ‘%26%’, before using them in your URL Query.
https://sgsglobal.sharepoint.com/sites/pwa2/_api/ProjectData/Projects/?$filter=Name eq ‘AT%26T’

Now you will be be able to get the results, as shown below.

image

The other special characters, that need to be encoded are as below:

image

More information could be found at: http://msdn.microsoft.com/en-us/library/aa226544(SQL.80).aspx