I use a REST call to get file information as:


Can I get the current file version using same REST call? If so how ?

This didn't workout http://MY_WEB_SITE/_api/web/lists/getByTitle('Documents')/items?$select=FileLeafRef,_UIVersionString

2 Answers 2


Here is the RESTful URL you need to get the current file version of a specific file (by its ID):


Here is the RESTful URL you need to get the current file version for all files in the library:


You can get the specific file's version using REST call by below given code.

// Get the file versions
    function getFileVersions() {
        var getfileurl = document.getElementById("getfileurl").value;
        var executor;
        // Initialize the RequestExecutor with the app web URL.
        executor = new SP.RequestExecutor(appweburl);
            url: appweburl + "/_api/SP.AppContextSite(@target)/web/GetFileByServerRelativeUrl('" + getfileurl + "')/Versions?@target='" + hostweburl + "'",
            method: "GET",
            headers: {
                "Accept": "application/json; odata=verbose"
            success: getFileVersionsSuccessHandler,
            error: getFileVersionsErrorHandler

    // Success Handler
    function getFileVersionsSuccessHandler(data) {
        var versions = 'File Versions:\n'
        var jsonObject = JSON.parse(data.body);
        var results = jsonObject.d.results;
        for (var i = 0; i < results.length; i++) {
            versions += results[i].VersionLabel + '\n';
        // Display the File versions

    // Error Handler
    function getFileVersionsErrorHandler(data, errorCode, errorMessage) {
        alert("Could not get the file versions: " + errorMessage);

Note:- Kindly change the variable values as per your environment.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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