5

I have a list named "St. John's Calendar". How do I use it with SP.CamlQuery? I'm thinking I need to encode it in some way, but nothing so far has worked.

Something like:

_api/web/lists/getbytitle('St. John's Calendar')/getitems
  • Does it work to do _api/web/lists/getbytitle("St. John's Calendar")/getitems instead? – Jordan Nov 24 '14 at 21:39
  • How do I use it with the REST api? What exactly do you want to do with the list ? – Amit Tyagi Nov 24 '14 at 21:39
  • Nope, changing to double quotes doesn't help. I just want to get the items in the list. – matt Nov 24 '14 at 21:43
  • How about _api/web/lists/getbytitle('St. John%27%27s Calendar')/getitems? – Slaven Semper Nov 24 '14 at 22:09
11

Works with double '

_api/Web/Lists/GetByTitle('St. John''s Calendar')/
  • I don't get it, but it does work... is there any documentation explaining that phenomenon ? – Michael Mar 12 '15 at 17:28
  • @Michael, sorry but I don't know. I used what I like to call the "hammering technique", where I rigorously pound on something until it works, a favorable approach in my world of SharePoint. – eirikb Mar 12 '15 at 19:27
  • I should however note that there is a similar question here, with a comment pointing to the odata docs, alas it turns out as 404, but is called AbstractTypeSystem. I would also note that I got a successful try quite early, as this approach is not uncommon practice in programming – eirikb Mar 12 '15 at 19:34
  • The peculiarity is actually mentioned here One of these rules is that single quotes within string literals are represented as two consecutive single quotes. – eirikb Mar 12 '15 at 19:43
1

You should switch back to Id in that case.

For example: First query

https://siteurl/_api/web/lists

and note down the guid of the list, then use

https://siteurl/_api/web/lists('6678c589-4a6b-4625-be62-ad5ddf97f1a7')/items

will give you the items

  • Yes, I will do this if I have to. But I want to know if there is a way of using the list name. – matt Nov 24 '14 at 21:50
  • I think Amal is right. The single quote in your list name St. John's Calendar must be causing the problem. So, try using List id. – Amit Tyagi Nov 24 '14 at 21:50
  • 1
    To clarify, I want to know if I can use the list name in some way, not switch to using guids. – matt Nov 24 '14 at 21:53
-3

If you are trying to get all the items of the list. You can try _api/web/lists/getbytitle('St. John's Calendar')/items .

Refer here for other options for getbytitle method.

  • This doesn't work because of the special characters in the list name. – matt Nov 24 '14 at 21:51

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.