Get the list id from its url using REST?

Juliano Nunes Silva Oliveira picture Juliano Nunes Silva Oliveira · Dec 12, 2016 · Viewed 9.4k times · Source

I'm using the SharePoint 2013 REST API to get and create list items, however the end users of my solution probably won't know how to find the list id, just the URL for one of its views, like http://spsportal/Lists/MyCalendar/calendar.aspx.

Is it possible to find the list ID using this URL?

Answer

baywet picture baywet · Dec 13, 2016

I can see at least two options:

  • GetByTitle REST method : The "MyCalendar" part of the url is the "simplified version" of the Title (meaning, if you had special characters, they'd be encoded).
    With a bit of Regex you should be able to extract the list name from the URL.
  • GetList /_api/web/GetList('/Lists/MyCalendar') The parameter has to be the server relative Url without the form information.

Just that you know, most of the methods available in SSOM are exposed on the REST API.