In this blog, I'll show you how to get the created date of SharePoint list using the REST API.
REST API Endpoint:
The following code snippet can be used in creating SharePoint Add-Ins,
-
- $.getScript(scriptbase + "SP.RequestExecutor.js", execCrossDomainRequest);
- });
-
- function execCrossDomainRequest() {
- var executor;
-
-
- executor = new SP.RequestExecutor(appweburl);
-
-
-
-
-
- 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 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;
- }
Embed Code Snippet:
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",
- method: "GET",
- headers: { "Accept": "application/json; odata=verbose" },
- success: function (data) {
- console.log(data.d.Created)
- }
- });
- </script>