I want to extract the "lastModifiedDateTime" from a list. I don't want to search the list by ID, but rather from its name. I know you can do it by MS graph, but the examples needs site ID as well as List ID. I want it in this similar form (tested in MS Graph explorer):

const SiteUrl = this.context.current.Web.Url;

SiteUrl+"/Lists/Project%20Information/AllItems.aspx/lastModifiedDateTime"

Does not work. Notice I want to use the current URL and hardcoded path (since all list have the same ending/name in the URL from provisioning, but the ID is different).

Is there any way I can use MS Graph to get the lastModifiedDateTime by site and list NAME and not ID? Or with Rest.

up vote 3 down vote accepted

You could use SP API _api/web/Lists/GetByTitle('listName') endpoint which returns list informations and deal with LastItemDeletedDate and LastItemModifiedDate. Here's a working code:

var requestUri = _spPageContextInfo.webAbsoluteUrl + '/_api/web/Lists/GetByTitle(\'stuff\')';
xhr = new XMLHttpRequest();
xhr.onreadystatechange = function() {
    if (this.readyState == XMLHttpRequest.DONE) {
        if(this.status == 200) {
            res = JSON.parse(this.responseText);
            console.log(res);
            console.log(res.d.LastItemModifiedDate);
        }
        else {
            console.log('Err. Could not return data.');
        }
    }
};

xhr.open('GET', requestUri, true);
xhr.setRequestHeader('accept', 'application/json;odata=verbose');
xhr.send(); 

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.