2016-04-08 84 views

回答

0

截止日期還有用於獲取文件的版本或修訂歷史沒有API資源。請按照link瞭解有關某個商務驅動器上的物品的可用操作。

0

您無法使用OneDrive for Business API來獲取文件修訂版(版本),但可以使用SharePoint API來獲取它們。

使用此鏈接來獲得文件版本:

其中:

「email_tenant_onmicrosoft_com」 - 是您的驅動器的電子郵件

「tenant-my.sharepoint.com」 - EndPoint of y我們的驅動

這個環節的響應看起來像這樣JSON:你

{ 
    "odata.metadata": "https://tenant-my.sharepoint.com/personal/email_tenant_onmicrosoft_com/_api/$metadata#SP.ApiData.FileVersions", 
    "value": [ 
    { 
     "odata.type": "SP.FileVersion", 
     "odata.id": "https://tenant-my.sharepoint.com/personal/email_tenant_onmicrosoft_com/_api/SP.FileVersionf1111111-aaaa-1234-5678-90abcdef1234", 
     "odata.editLink": "SP.FileVersionf1111111-aaaa-1234-5678-90abcdef1234", 
     "CheckInComment": "", 
     "Created": "2013-04-27T15:57:57Z", 
     "ID": 512, 
     "IsCurrentVersion": false, 
     "Length": "5716", 
     "Size": 5716, 
     "Url": "_vti_history/512/Documents/TEST_005.xlsx", 
     "VersionLabel": "1.0" 
    }, 
    { 
     "odata.type": "SP.FileVersion", 
     "odata.id": "https://tenant-my.sharepoint.com/personal/email_tenant_onmicrosoft_com/_api/SP.FileVersion2ab46e3e-9614-43ff-ad03-252b1f4d0d90", 
     "odata.editLink": "SP.FileVersion2ab46e3e-9614-43ff-ad03-252b1f4d0d90", 
     "CheckInComment": "", 
     "Created": "2013-04-27T15:58:39Z", 
     "ID": 1024, 
     "IsCurrentVersion": false, 
     "Length": "7868", 
     "Size": 7868, 
     "Url": "_vti_history/1024/Documents/TEST_005.xlsx", 
     "VersionLabel": "2.0" 
    }, 
    { 
     "odata.type": "SP.FileVersion", 
     "odata.id": "https://tenant-my.sharepoint.com/personal/email_tenant_onmicrosoft_com/_api/SP.FileVersion42f5f367-05ca-4131-84bf-79e7a6c0f77d", 
     "odata.editLink": "SP.FileVersion42f5f367-05ca-4131-84bf-79e7a6c0f77d", 
     "CheckInComment": "", 
     "Created": "2013-04-27T15:58:43Z", 
     "ID": 1536, 
     "IsCurrentVersion": false, 
     "Length": "7868", 
     "Size": 7868, 
     "Url": "_vti_history/1536/Documents/TEST_005.xlsx", 
     "VersionLabel": "3.0" 
    } 
    ] 
} 

重要的參數是:

「odata.editLink」「SP.FileVersion」之後 - 這是唯一的文件版本編號。 「ID」 - 它是當前文件的版本ID。

要下載文件的版本,你可以使用這個鏈接:

,其中「1024 「 - 來自JSON的字段」ID「。

若要獲取有關項目的最後版本信息,您可以使用此鏈接:

響應鏈接看起來像這樣JSON:

{ 
    "odata.metadata": "https://tenant-my.sharepoint.com/personal/email_tenant_onmicrosoft_com/_api/$metadata#SP.ApiData.Files12/@Element", 
    "odata.type": "SP.File", 
    "odata.id": "https://tenant-my.sharepoint.com/personal/email_tenant_onmicrosoft_com/_api/Web/GetFileByServerRelativeUrl('/personal/email_tenant_onmicrosoft_com/Documents/TEST_005.xlsx')", 
    "odata.editLink": "Web/GetFileByServerRelativeUrl('/personal/email_tenant_onmicrosoft_com/Documents/TEST_005.xlsx')", 
    "CheckInComment": "", 
    "CheckOutType": 2, 
    "ContentTag": "{C4B73433-8AED-44C2-862A-746EBA4599EB},11,7", 
    "CustomizedPageStatus": 0, 
    "ETag": "\"{C4B73433-8AED-44C2-862A-746EBA4599EB},11\"", 
    "Exists": true, 
    "IrmEnabled": false, 
    "Length": "7923", 
    "Level": 1, 
    "LinkingUri": "https://tenant-my.sharepoint.com/personal/email_tenant_onmicrosoft_com/Documents/TEST_005.xlsx?d=wc4b734338aed44c2862a746eba4599eb", 
    "LinkingUrl": "https://tenant-my.sharepoint.com/personal/email_tenant_onmicrosoft_com/Documents/TEST_005.xlsx?d=wc4b734338aed44c2862a746eba4599eb", 
    "MajorVersion": 4, 
    "MinorVersion": 0, 
    "Name": "TEST_005.xlsx", 
    "ServerRelativeUrl": "/personal/email_tenant_onmicrosoft_com/Documents/TEST_005.xlsx", 
    "TimeCreated": "2013-04-27T15:57:55Z", 
    "TimeLastModified": "2013-04-27T15:59:28Z", 
    "Title": null, 
    "UIVersion": 2048, 
    "UIVersionLabel": "4.0", 
    "UniqueId": "c4b73433-8aed-44c2-862a-746eba4599eb" 
} 

你可以使用這個信息,當您添加文件的一個新版本。

「UniqueId」 - 它是JSON版本中的「odata.editLink」的正確部分。 「UIVersion」 - 它是JSON版本中的「ID」。

要下載文件的最後一個版本 - 使用此鏈接:

鏈接:

不起作用。它會工作,如果你添加此文件的新版本。

您可以通過使用OneDrive API鏈接下載項目的最後一個版本:

但如果你使用服務帳戶驗證此鏈接不起作用

相關問題