Years ago I wrote a little article on how to find SharePoint GUIDs for SharePoint 2007. Later I wrote one on how to find the same GUIDs using PowerShell.
Now, here's how to find GUIDs for just about anything using SharePoint 2013's REST web services! The following will work for both on premises and SharePoint Online / Office 365.
---
SharePoint 2013 includes a REST service to access sites, lists and items. In the data that's returned is an ID that is the GUID for the item.
Accessing REST is quite easy as you only need to type it into the address bar of your browser! REST does not work around security, so you will still need to authenticate to your site.
In the examples below "yourdomain" will of course be replaced with your domain name. If using Office 365 it might look like "http://companyname.sharepoint.com.
If you get a result that looks like this…
… you can either use the View Source feature of the browser to see the XML or change the way the browser displays XML. For Internet Explorer: Tools, Internet Options, Content tab, Feeds and Web Slices Settings and then uncheckmark "Turn on feed reading view",
Getting the GUID for your subsite (and a lot more…)
Visit your site, login and then edit your URL to look like this:
https://yourdomain.sharepoint.com/sites/yoursite/yoursubsite/_api/web
Scroll down to the content section and look for the ID element.
For other objects… sites, lists, items, fields, users…
See the references at the end of this article for even more examples.
The current site collection:
/_api/Site
Web and Site Features and their GUIDs:
/_api/web/Features
/_api/site/Features
Lists:
/_api/web/Lists
A single list (by name):
/_api/web/Lists/getbytitle('tasks')
/_api/web/Lists(guid'c61dc1a2-4982-4dc8-9d78-603d83d81940') (of course using your list's GUID!)
All list items:
/_api/web/Lists/getbytitle('tasks')/items
A single list item:
/_api/web/Lists/getbytitle('tasks')/items(12) (Item with the ID of 12)
List items by criteria:
/_api/web/Lists/getbytitle('tasks')/items?$filter=Status eq 'Not Started'
All list columns, including both display name and internal name!
/_api/web/Lists/getbytitle('tasks')/Fields
Especially note these two elements:
<d:InternalName>PercentComplete</d:InternalName>
<d:Title>% Complete</d:Title>
The current user:
/_api/web/CurrentUser (No GUID here, but there are other goodies!)
There's a lot more that you can do with SharePoint 2013's REST services!
- Understanding and Using the SharePoint 2013 REST Interface
http://msdn.microsoft.com/en-us/magazine/dn198245.aspx - REST API reference and samples
http://msdn.microsoft.com/en-us/library/office/jj860569.aspx - or just to a search!
http://www.bing.com/search?q=sharepoint+2013+rest
.
3 comments:
Thanks Mike, i was looking for this solution to find my sub site GUID, you saved my day.
How would you use this solution to find a lists WebID?
JKline,
"WebID", as in the ID of the SPWeb? That's the first example above.
https://yourdomain.sharepoint.com/sites/yoursite/yoursubsite/_api/web
or for the top level web:
https://yourdomain.sharepoint.com/_api/web
Mike
Post a Comment