Search code examples
restsharepointodatasharepoint-2013

"The expression is not valid" when performing SharePoint Rest call


I have a SharePoint site and when I call

    SITE/_api/web/lists/  

it gives me the data for all the lists no problem. The problem is once I start querying for a specific list (for example one called "Environments") by calling

    SITE/_api/web/lists/getbytitle("Environments")/   

it gives me the error

    Microsoft.SharePoint.Client.InvalidClientQueryExceptionThe expression "web/lists/getbytitle(Environments)/items" is not valid. 

Am I not building the URL right or is there something wrong with the site.


Solution

  • Use apostrophes (') instead of quotation marks around the title of your list.

    If your list tile has apostrophes in its title, you need to escape those by replacing each apostrophe with %27%27.