This article explains how to get the Root website properties using the REST API.
The following REST API URL represents the Site Collection object that can retrieve the properties based on the given SharePoint Site URL.
http://sharepointsite/_api/site
The preceding REST API URL consists of site collection properties. From the collection of all properties, we need to use the “RootWeb” property to retrieve the top-level website properties.
Syntax
http://sharepointsite/_api/site/rootweb
The preceding SharePoint REST URL returns the following properties of the root website,
Property |
Type |
Value |
AllowRssFeeds |
Boolean |
TRUE |
AppInstanceId |
Guid |
00000000-0000-0000-0000-000000000000 |
Configuration |
Int16 |
0 |
Created |
DateTime |
2015-03-16T12:06:54 |
CustomMasterUrl |
string |
/_catalogs/masterpage/seattle.master |
Description |
string |
|
DocumentLibraryCalloutOfficeWebAppPreviewersDisabled |
Boolean |
FALSE |
EnableMinimalDownload |
Boolean |
FALSE |
Id |
Guid |
c3aaa420-ae4b-4355-b5e2-2b27516f2fec |
Language |
Int32 |
1033 |
LastItemModifiedDate |
DateTime |
2015-04-23T09:56:00Z |
MasterUrl |
string |
/_catalogs/masterpage/seattle.master |
QuickLaunchEnabled |
Boolean |
TRUE |
RecycleBinEnabled |
Boolean |
TRUE |
ServerRelativeUrl |
string |
/ |
SyndicationEnabled |
Boolean |
TRUE |
Title |
string |
|
TreeViewEnabled |
Boolean |
TRUE |
UIVersion |
Int32 |
15 |
UIVersionConfigurationEnabled |
Boolean |
FALSE |
URL |
string |
|
WebTemplate |
string |
STS |
Properties
- AllowRssFeeds
Retrieve the Boolean value that specifies whether the web site allows RSS feeds.
- AppInstanceId
Retrieves the App Instance Id of the web.
- Configuration
Retrieves the id of the Site definition or id of the Site template, from which the web site is created.
- Created
Returns the web site created date with time.
- CustomMasterUrl
Returns the URL of the custom master page applied to the site.
- Description
Returns the description of the web site.
- DocumentLibraryCalloutOfficeWebAppPreviewersDisabled
Returns the Boolean value that specifies whether the Web App Previewer is disabled for the site.
- EnableMinimalDownload
Returns the Boolean value that specifies whether the minimal download option is enabled for the site.
- Id
Returns the ID of the site in GUID format.
- Language
Returns the language code that is applied to the site.
- LastItemModifiedDate
Returns the date of the items that was last modified in the site.
- MasterUrl
Returns the URL of the default master page applied to the site.
- QuickLaunchEnabled
Returns the Boolean value that specifies whether the quick launch is enabled for the site.
- RecycleBinEnabled
Returns the Boolean value that specifies whether the recyclebin is enabled for the site.
- ServerRelativeUrl
Returns the server relative URL of the top level site.
- SyndicationEnabled
Retuns the Boolean value that specifies whether the RSS feed is enabled for the site.
- Title
Returns the Title of the top level site.
- TreeViewEnabled
Returns the Boolean value that specifies whether the tree view is enabled for the site.
- UIVersion
Returns the UI version used for the site.
- UIVersionConfigurationEnabled
Returns the Boolean value that specifies whether the settings UI for visual upgrade is shown or hidden for the site.
- Url
Returns the absolute URL for the website.
- WebTemplate
Returns the name of the site definition or site template that was used to create the top level website.
Example Code
The following code requests the root web information using the REST API, with the help jQuery ajax call and displays the properties of the root in a browser console.
- < script type = "text/javascript" src = "/siteassets/jquery.min.js" > < /script>
- <script type="text/javascript">
-
- jQuery.ajax({
- url: "
- https:
- type: "GET",
- headers: {
- "accept": "application/json;odata=verbose",
- "content-type": "application/json;odata=verbose",
- "X-RequestDigest": $("#__REQUESTDIGEST").val()
- },
- success: function(data) {
- Rootwebdetails(data);
- },
- error: function() {
- console.log('fail');
- }
- });
-
- function Rootwebdetails(data)
- {
- console.log("Allow RSS Feeds: " + data.d.AllowRssFeeds);
- console.log("AppInstanceId: " + data.d.AppInstanceId);
- console.log("Configuration: " + data.d.Configuration);
- console.log("Created: " + data.d.Created);
- console.log("CustomMasterUrl: " + data.d.CustomMasterUrl);
- console.log("Description: " + data.d.Description);
- console.log("DocumentLibraryCalloutOfficeWebAppPreviewersDisabled: " + data.d.DocumentLibraryCalloutOfficeWebAppPreviewersDisabled);
- console.log("EnableMinimalDownload: " + data.d.EnableMinimalDownload);
- console.log("Id: " + data.d.Id);
- console.log("Language: " + data.d.Language);
- console.log("LastItemModifiedDate: " + data.d.LastItemModifiedDate);
- console.log("MasterUrl: " + data.d.MasterUrl);
- console.log("QuickLaunchEnabled: " + data.d.QuickLaunchEnabled);
- console.log("RecycleBinEnabled: " + data.d.RecycleBinEnabled);
- console.log("ServerRelativeUrl: " + data.d.ServerRelativeUrl);
- console.log("SyndicationEnabled: " + data.d.SyndicationEnabled);
- console.log("Title: " + data.d.Title);
- console.log("TreeViewEnabled: " + data.d.TreeViewEnabled);
- console.log("UIVersion: " + data.d.UIVersion);
- console.log("UIVersionConfigurationEnabled: " + data.d.UIVersionConfigurationEnabled);
- console.log("Url: " + data.d.Url);
- console.log("WebTemplate: " + data.d.WebTemplate);
- }
- < /script>
Summary
The root web properties can be accessed directly from the REST URL, with specification of the index number, web title or URL. These properties can be used in many ways during the creation of Apps or other root web related client-side applications.