In this blog, I'll show you how to get the created date of SharePoint list using the REST API.
REST API Endpoint:
- https://sharepointsiteurl/_api/web/getByTitle('ListName')?$select=created
The following code snippet can be used in creating SharePoint Add-Ins,
- // Load the cross-domain library JS file
- $.getScript(scriptbase + "SP.RequestExecutor.js", execCrossDomainRequest);
- });
- function execCrossDomainRequest() {
- var executor;
- // Initialize the RequestExecutor with the app web URL.
- executor = new SP.RequestExecutor(appweburl);
- // To get the title using REST we can hit the endpoint:
- // app_web_url/_api/SP.AppContextSite(@target)/web/lists/getByTitle('ListName')?$select=Created&@target='siteUrl'
- // The response formats the data in the JSON format.
- executor.executeAsync({
- url: appweburl + "/_api/SP.AppContextSite(@target)/web/lists/getByTitle('TestList')?$select=Created&@target='" + hostweburl + "'",
- method: "GET",
- headers: {
- "Accept": "application/json; odata=verbose"
- },
- success: successHandler,
- error: errorHandler
- });
- }
- // Function to handle the success event.
- // Prints the host web's title to the page.
- function successHandler(data) {
- var jsonObject = JSON.parse(data.body);
- console.log('List Created Date: ' + jsonObject.d.Created);
- }
- function errorHandler(data, errorCode, errorMessage) {
- console.log("Could not complete cross-domain call: " + errorMessage;
- }
The following code snippet can be embedded in SharePoint page or Content editor webpart to get the output using REST API,
- <script type="text/javascript" src="/SiteAssets/Scripts/jquery-1.9.1.min.js"></script>
- <script type="text/javascript">
- $.ajax({
- url: _spPageContextInfo.webAbsoluteUrl+"/_api/web/lists/getByTitle('TestList')?$select=created", //THE ENDPOINT
- method: "GET",
- headers: { "Accept": "application/json; odata=verbose" },
- success: function (data) {
- console.log(data.d.Created) //RESULTS HERE!!
- }
- });
- </script>

Join the conversation! Your thoughts help the community grow.