Get List Created date using SharePoint REST API

In this blog, I'll show you how to get the created date of SharePoint list using the REST API.
 
REST API Endpoint:
  1. https://sharepointsiteurl/_api/web/getByTitle('ListName')?$select=created  
Add-In Code snippet:

The following code snippet can be used in creating SharePoint Add-Ins, 
  1. // Load the cross-domain library JS file  
  2. $.getScript(scriptbase + "SP.RequestExecutor.js", execCrossDomainRequest);  
  3. });  
  4.   
  5. function execCrossDomainRequest() {  
  6.     var executor;  
  7.   
  8.     // Initialize the RequestExecutor with the app web URL.  
  9.     executor = new SP.RequestExecutor(appweburl);  
  10.   
  11.     // To get the title using REST we can hit the endpoint:  
  12.     //      app_web_url/_api/SP.AppContextSite(@target)/web/lists/getByTitle('ListName')?$select=Created&@target='siteUrl'  
  13.     // The response formats the data in the JSON format.  
  14.   
  15.     executor.executeAsync({  
  16.         url: appweburl + "/_api/SP.AppContextSite(@target)/web/lists/getByTitle('TestList')?$select=Created&@target='" + hostweburl + "'",  
  17.         method: "GET",  
  18.         headers: {  
  19.             "Accept""application/json; odata=verbose"  
  20.         },  
  21.         success: successHandler,  
  22.         error: errorHandler  
  23.     });  
  24. }  
  25.   
  26. // Function to handle the success event.  
  27. // Prints the host web's title to the page.  
  28. function successHandler(data) {  
  29.     var jsonObject = JSON.parse(data.body);  
  30.     console.log('List Created Date: ' + jsonObject.d.Created);  
  31.   
  32. }  
  33.   
  34. function errorHandler(data, errorCode, errorMessage) {  
  35.     console.log("Could not complete cross-domain call: " + errorMessage;  
  36. }  
Embed Code Snippet:

The following code snippet can be embedded in SharePoint page or Content editor webpart to get the output using REST API, 
  1. <script type="text/javascript" src="/SiteAssets/Scripts/jquery-1.9.1.min.js"></script>  
  2.   
  3. <script type="text/javascript">  
  4. $.ajax({  
  5.    url: _spPageContextInfo.webAbsoluteUrl+"/_api/web/lists/getByTitle('TestList')?$select=created"//THE ENDPOINT  
  6.    method: "GET",  
  7.    headers: { "Accept""application/json; odata=verbose" },  
  8.    success: function (data) {  
  9.         console.log(data.d.Created) //RESULTS HERE!!  
  10.    }  
  11. });  
  12. </script>  
X

Build smarter apps with Machine Learning, Bots, Cognitive Services - Start free.

Start Learning Now