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

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.

  1. < script type = "text/javascript" src = "/siteassets/jquery.min.js" > < /script>
  2. <script type="text/javascript">
  3. //jQuery ajax used to call the REST API and get the response
  4. jQuery.ajax({
  5. url: "
  6. https: //sharepointsite/_api/site/rootweb",
  7. type: "GET",
  8. headers: {
  9. "accept": "application/json;odata=verbose",
  10. "content-type": "application/json;odata=verbose",
  11. "X-RequestDigest": $("#__REQUESTDIGEST").val()
  12. },
  13. success: function(data) {
  14. Rootwebdetails(data);
  15. },
  16. error: function() {
  17. console.log('fail');
  18. }
  19. });
  20. //Rootwebdetails method used to log the results to the browser console
  21. function Rootwebdetails(data)
  22. {
  23. console.log("Allow RSS Feeds: " + data.d.AllowRssFeeds);
  24. console.log("AppInstanceId: " + data.d.AppInstanceId);
  25. console.log("Configuration: " + data.d.Configuration);
  26. console.log("Created: " + data.d.Created);
  27. console.log("CustomMasterUrl: " + data.d.CustomMasterUrl);
  28. console.log("Description: " + data.d.Description);
  29. console.log("DocumentLibraryCalloutOfficeWebAppPreviewersDisabled: " + data.d.DocumentLibraryCalloutOfficeWebAppPreviewersDisabled);
  30. console.log("EnableMinimalDownload: " + data.d.EnableMinimalDownload);
  31. console.log("Id: " + data.d.Id);
  32. console.log("Language: " + data.d.Language);
  33. console.log("LastItemModifiedDate: " + data.d.LastItemModifiedDate);
  34. console.log("MasterUrl: " + data.d.MasterUrl);
  35. console.log("QuickLaunchEnabled: " + data.d.QuickLaunchEnabled);
  36. console.log("RecycleBinEnabled: " + data.d.RecycleBinEnabled);
  37. console.log("ServerRelativeUrl: " + data.d.ServerRelativeUrl);
  38. console.log("SyndicationEnabled: " + data.d.SyndicationEnabled);
  39. console.log("Title: " + data.d.Title);
  40. console.log("TreeViewEnabled: " + data.d.TreeViewEnabled);
  41. console.log("UIVersion: " + data.d.UIVersion);
  42. console.log("UIVersionConfigurationEnabled: " + data.d.UIVersionConfigurationEnabled);
  43. console.log("Url: " + data.d.Url);
  44. console.log("WebTemplate: " + data.d.WebTemplate);
  45. }
  46. < /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.