フォルダを復元

post
https://api.box.com/2.0
/folders/:folder_id

ごみ箱に移動されたフォルダを復元します。

元のフォルダが削除されている場合にフォルダの復元先となる新しい親ID (省略可) を指定することができます。

フォルダのロック

この操作の進行中は、ファイルツリーの一部がロックされます。ロックされるのは主に元のフォルダとその子孫フォルダ、および宛先フォルダです。

操作の進行中は、ロックされたどのフォルダに対しても、その他の移動、コピー、削除または復元操作を実行できません。

リクエスト

bearer [ACCESS_TOKEN]
application/json

パスパラメータ

stringパス内必須
12345

フォルダを表す一意の識別子。

フォルダIDを確認するには、ウェブアプリケーションでこのフォルダにアクセスして、URLからIDをコピーします。たとえば、URLがhttps://*.app.box.com/folder/123の場合、folder_id123です。

Boxアカウントのルートフォルダは常にID 0で表されます。

クエリパラメータ

string arrayクエリ内省略可能
id,type,name

レスポンスに含める属性のコンマ区切りリスト。このパラメータを使用すると、標準のレスポンスには通常含まれないフィールドをリクエストできます。

このパラメータを指定すると、明示的に指定しない限り標準フィールドはレスポンスに含まれず、リクエストしたフィールドのほかには、Mini版の表示のフィールドしか返されないことに注意してください。

リクエスト本文

string本文内省略可能
"Restored Photos"

フォルダの新しい名前 (省略可)。

object本文内

元のフォルダがすでに存在しない場合にフォルダの復元先となるフォルダのID (省略可) を指定します。

このIDは、元のフォルダがすでに存在しない場合にのみ使用されることに注意してください。このIDは、元の場所が削除されている場合にフォルダの復元先となるフォールバックの場所を指定します。

string本文内省略可能
"123"

親項目のID

レスポンス

フォルダが復元されたときにフォルダオブジェクトを返します。

フォルダの復元先フォルダに対してユーザーがアクセス権限を持っていない場合、またはごみ箱からフォルダを復元する権限を持っていない場合は、エラーを返します。

フォルダがごみ箱内にない場合は、エラーを返します。

  • 宛先フォルダに同じ名前のフォルダがある場合はエラーを返します。

  • operation_blocked_temporary: 別の移動、コピー、削除、または復元操作が進行中であるために宛先フォルダまたは元のフォルダがロックされている場合に返されます。

    操作は後で再試行することができます。

予期しないクライアントエラー。

post
フォルダを復元
このドキュメント内で一部のAPIを試せるようになりました。
ログイン

リクエストの例

cURL
curl -i -X POST "https://api.box.com/2.0/folders/4353455" \
     -H "authorization: Bearer <ACCESS_TOKEN>"
.NET
var requestParams = new BoxFolderRequest()
{
    Name = "Name in case of conflict",
    Parent = new BoxRequestEntity()
    {
        // Folder will be placed in this parent folder if original location no longer exists
        Id = "12345" 
    }
};
BoxFolder restoredFolder = await client.FoldersManager.RestoreTrashedFolderAsync(requestParams);
Java
String folderID = "125367";
String newName = "My Documents ORIGINAL";
String newParentID = "98765";

BoxTrash trash = new BoxTrash(api);
// Avoid conflicts at the original location
trash.restoreFolder(folderID, newName, newParentID);
Python
folder_to_restore = client.folder(folder_id='22222')
restored_folder = client.trash().restore_item(folder_to_restore)
print(f'Folder ID is {restored_folder.id} and name is {restored_folder.name}')
Node
client.folders.restoreFromTrash(
	'22222',
	{
		// New name in case of conflict
		name: 'New Name',
		// Folder will be placed in this parent folder if the original parent no longer exists
		parent_id: '0'
	})
	.then(restoredFolder => {
		/* trashedFolder -> {
			type: 'folder',
			id: '22222',
			sequence_id: '1',
			etag: '1',
			name: 'Old Files',
			created_at: '2013-05-06T22:37:30-07:00',
			modified_at: '2013-05-06T22:39:08-07:00',
			description: '',
			size: 18482,
			path_collection: 
			{ total_count: 1,
				entries: 
				[ { type: 'folder',
					id: '0',
					sequence_id: null,
					etag: null,
					name: 'All Files' } ] },
			created_by: 
			{ type: 'user',
				id: '33333',
				name: 'Example User',
				login: 'user@example.com' },
			modified_by: 
			{ type: 'user',
				id: '33333',
				name: 'Example User',
				login: 'user@example.com' },
			trashed_at: null,
			purged_at: null,
			content_created_at: '2013-05-06T22:37:30-07:00',
			content_modified_at: '2013-05-06T22:39:08-07:00',
			owned_by: 
			{ type: 'user',
				id: '33333',
				name: 'Example User',
				login: 'user@example.com' },
			shared_link: null,
			folder_upload_email: null,
			parent: 
			{ type: 'folder',
				id: '0',
				sequence_id: null,
				etag: null,
				name: 'All Files' },
			item_status: 'active' }
		*/
	});

レスポンスの例

{
  "id": "123456789",
  "type": "folder",
  "content_created_at": "2012-12-12T10:53:43-08:00",
  "content_modified_at": "2012-12-12T10:53:43-08:00",
  "created_at": "2012-12-12T10:53:43-08:00",
  "created_by": {
    "id": "11446498",
    "type": "user",
    "login": "ceo@example.com",
    "name": "Aaron Levie"
  },
  "description": "Legal contracts for the new ACME deal",
  "etag": "1",
  "folder_upload_email": "null",
  "item_status": "active",
  "modified_at": "2012-12-12T10:53:43-08:00",
  "modified_by": {
    "id": "11446498",
    "type": "user",
    "login": "ceo@example.com",
    "name": "Aaron Levie"
  },
  "name": "Contracts",
  "owned_by": {
    "id": "11446498",
    "type": "user",
    "login": "ceo@example.com",
    "name": "Aaron Levie"
  },
  "parent": {
    "id": "12345",
    "type": "folder",
    "etag": "1",
    "name": "Contracts",
    "sequence_id": "3"
  },
  "path_collection": {
    "entries": [
      {
        "id": "12345",
        "etag": "1",
        "type": "folder",
        "sequence_id": "3",
        "name": "Contracts"
      }
    ],
    "total_count": 1
  },
  "purged_at": "null",
  "sequence_id": "3",
  "shared_link": "null",
  "size": 629644,
  "trashed_at": "null"
}