I am trying to fetch record from list with RESP API.I want to filter record with 'eq'.

following is the rest endpoint which I am trying,

_api/Web/Lists/GetByTitle('Experts')/items?$select=Column1,Column2$filter=Column1 eq 'A&B'

I am getting following error,

The expression "Column1 eq 'A" is not valid.

Any Idea?


It might help to explain the Why with an answer,

The & character indicates a new Variable IN the URI string,

If you need it as a character, you have to escape it,
telling the Server not to threat it as a separator.

Multiple methods of escaping characters:

Comparing escape(), encodeURI(), and encodeURIComponent()


try below code

<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script>
    $(document).ready(function () {
    // Executing our items via an ajax request 
    var colVal = encodeURIComponent("A&B");
        url: "siteurl/_api/web/lists/getbytitle('test')/items?$select=Title&$filter=Title eq '"+colVal+"'",
        method: "GET",
        headers: { "Accept": "application/json; odata=verbose" },
        success: function (data) {
            console.log(data); // Returns JSON collection of the results
        error: function (data) {


URL parameter values should be encoded while using them in REST.

var colVal = encodeURIComponent("A&B");

then use this variable in your query.

var endPointURL = _spPageContextInfo.webAbsoluteUrl + "/_api/Web/Lists/GetByTitle('Experts')/items?$select=Column1,Column2$filter=(Column1 eq '" + colVal + "')"

Can you please try below URL.

http://siteURL/_api/Web/Lists/GetByTitle('Experts')/items?$select=Column1,Column2$filter=Column1 eq 'A\&B'

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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