I need to get information about all the minor versions of a specific list or library using REST API. I tried it with


But it didn't get what I wanted.


Try this code . I hope , u will get your required Output.

function getMinorVersion() {
        var getfilename = document.getElementById("getfilename").value;
        var executor;

        // Initialize the RequestExecutor with the app web URL.
        executor = new SP.RequestExecutor(appweburl);
            url: appweburl + "/_api/SP.AppContextSite(@target)/web/getfolderbyserverrelativeurl('/Shared%20Documents/FolderA')/files('" + getfilename + "')/MinorVersion?@target='" + hostweburl + "'",
            method: "GET",
            headers: {
                "Accept": "application/json; odata=verbose"
            success: getMinorVersionSuccessHandler,
            error: getMinorVersionErrorHandler

It does not seem possible to get versions for a List Item via REST/CSOM APIs, but there are alternative options

Using Versions.aspx application page

The idea is to perform a get request to Versions page:



function getItemVersions(url,listId,itemId,success)
   var versionsUrl = url + '/_layouts/versions.aspx?list=' + listId + '&ID=' + itemId;  
   $.get( versionsUrl, function( data ) {
      var versionEntries = parseVersionList(data);

function parseVersionList(data){
   var entries = {};
   var versionList = $(data).find('table.ms-settingsframe');

   versionList.find('tbody > tr').each(function(i){
     if(i > 0 && (i-1) % 2 == 0) {
        var verRow = $(this); //get version row
        var propsRow = verRow.next(); //get properties row
        var versionLabel = verRow.find('td:first').html().trim();
        entries[versionLabel] = {};
        //extract item properties from propsRow goes here

   return entries;

var webUrl = _spPageContextInfo.webAbsoluteUrl;
var listId = _spPageContextInfo.pageListId;
var listItemId = 1;

Now from the above code, you can differentiate the minor versions inside parseVersionList function.

  • what about the CORS? I get CORs error using this code in a provider hosted app. Is it possible? – Flezcano Jul 27 '17 at 23:49

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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