1

Is it possible to retrieve all versions of list items using REST? or at-least any other way of achieving it using javascript/jquery?

I have followed https://stackoverflow.com/questions/24423657/sharepoint-2013-get-splistitem-versions-via-rest article and there is a answer using version page but i am not able to retrieve the field values from the response i get from that solution. I just get Objectas a response

2
/_api/lists/getbytitle('Projects')/Items(1)/versions
  • 1
    Not working. Are you sure it is valid API? – SharePointMan May 22 '18 at 6:14
  • yep, works for me. – Derek Gusoff May 22 '18 at 13:03
  • 2013 on prem didn't have this when first shipped. It works for SharePoint online, but I don't know if it became available on prem with 2019, or 2016, or 2013 +some service pack? – Joe McShea Feb 15 at 20:01
1

It is because you write versionEntries to the console. It is an object. If you are using IE, it will display as object instead of data in console. You can try using Chrome and check the console output value, it will display data from the object.

You can also try to use the SharePoint List web service that exposes Lists.GetVersionCollection Method to return version information for an item in a SharePoint list.

Here is a code demo to retrieve a list item version, it works.

<script type="text/javascript" src="http://code.jquery.com/jquery-1.10.1.min.js"></script>
<script type="text/javascript" src="http://cdnjs.cloudflare.com/ajax/libs/jquery.SPServices/0.7.1a/jquery.SPServices-0.7.1a.min.js"></script>
<script type="text/javascript">
$(function(){
                $().SPServices({
                                 operation: "GetVersionCollection",
                                  async: false,
                                  strlistID: "Lists_1",
                                  strlistItemID: 1,
                                  strFieldName: "Title",
                                  completefunc: function (xData, Status) {
                                  console.log(xData);
                                    $(xData.responseText).find("Version").each(function(i) {
                                      console.log("Name: " + $(this).attr("Title") + " Modified: " + $(this).attr("Modified"));
                                    });  
                                  }
                }); 
});
</script>
0

If you are working with a document library instead of a list, use:

_api/lists/getbytitle('FooLibrary')/Items(48)/File/Versions
  • BTW, this works for lists too in SharePoint online. I don't know which, if any, versions of on prem it works for. – Joe McShea Feb 15 at 19:56

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.