1

How to reproduce the problem:

  • Have a list with a title: Mapped Drives / Folder Redirection
  • Open this list using this URL https://tenant.sharepoint.com/_api/web/lists/GetByTitle('Mapped Drives / Folder Redirection')
  • Or open it using this url: https://tenant.sharepoint.com/_api/web/lists/GetByTitle('Mapped%20Drives%20%2F%20Folder%20Redirection')

The result is: enter image description here

I've found a similar question, but it does not have a solution. At least none that would solve the problem of having a slash in the title SharePoint REST API getbytitle with ampersand in title?

Is there are way to query a list by title via REST if it contains a slash symbol?

2

The REST API Lists/getByTitle('') does not support the special character /. You have to get it by using one of the following ways.

Using GUID

https://tenant.sharepoint.com/_api/web/Lists(guid'your guid')

Using Filter Operation

https://tenant.sharepoint.com/_api/web/Lists?$filter=Title eq 'your list title'

If you want to get the items from the list using the title. You have to make 2 calls.

  1. Get List Guid from below query. Example

    https://tenant.sharepoint.com/_api/web/Lists?$filter=Title eq 'test/List'&$select=Id

  2. Use the Id from the above response to get the items

    https://tenant.sharepoint.com/_api/web/Lists(guid'guid from above request')/Items

0

Although you came up with a workaround, I'm curious whether either of these suggestions would have worked for you:

  • Use the URL encoded version of the call
    • Mapped Drives / Folder Redirection would be Mapped%20Drives%20%2F%20Folder%20Redirection
    • It should be valid OData call as per this
  • Wrap the title with encodeURIComponent():
    • /getByTitle('" + encodeURIComponent('Mapped Drives / Folder Redirection') + "')

I have come up with findings of both of the mentioned where they have worked in a similar case.

  • Hi Moe, thank you for the answer. As you can see, encodeURIComponent('Mapped Drives / Folder Redirection') produces Mapped%20Drives%20%2F%20Folder%20Redirection. And this is exactly what I used in the question and specified that it throws an error. as Venkat Konjeti said, you cannot get run Lists/getByTitle('') if the list contains a slash symbol. No matter if you try to escape it with encodeURIComponent or not. – Denis Molodtsov Jun 13 '17 at 15:17
  • Cheers @DenisMolodtsov, kinda what I was expecting. Why I still suggested this was because I have come across cases where getByTitle is successfully used with special characters, which made me question the unambiguous explanation here. – moe Jun 13 '17 at 15:20
  • I really like the $filter=Title eq 'your list title' solution since it produces nearly identical response as Lists/getByTitle(''). And I don't need to make 2 calls instead of one. – Denis Molodtsov Jun 13 '17 at 15:26

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.