2016-04-08 14 views
1

OneDrive for Business(REST API)を当社のプラットフォームに統合しようとしています。アップロードAPIを使用してファイルをアップロードし、ファイルの内容を更新できます。しかし、どのようにファイルのリビジョン履歴を取得するのですか?私が使用しているAPIを以下に示します。日付までOneDrive for Business APIを使用してファイルのリビジョン履歴を取得する方法

Upload a file

答えて

0

ファイルのバージョンまたは改訂履歴を取得するためのAPIリソースがありません。 linkに従って、1つのドライブ内のアイテムの使用可能な操作についてビジネス情報を入手してください。

0

Business APIにOneDriveを使用してファイルリビジョン(バージョン)を取得することはできませんが、SharePoint APIを使用して入手できます。

使用するファイルのバージョンを取得するには、このリンク:

場所:

"email_tenant_onmicrosoft_com" - あなたのドライブのメールアドレス

"tenant-my.sharepoint.com" - エンドポイントの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" 
    } 
    ] 
} 

重要なパラメータは次のとおりです。

「SP.FileVersion」の後に「odata.editLink」 - それはファイルバージョンの一意のIDです。 "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のリンクを使用してアイテムの最後のリビジョンをダウンロードすることができます。

いますが、サービスアカウント認証を使用する場合は、このリンクは機能しません

関連する問題