フォルダの作成
フォルダの作成
Box上でフォルダを作成するには、新しいフォルダのname
と、新しいフォルダの作成先になるparent
フォルダのid
をAPIに渡す必要があります。
cURL
curl -i -X POST "https://api.box.com/2.0/folders" \
-H "authorization: Bearer <ACCESS_TOKEN>" \
-H "content-type: application/json" \
-d '{
"name": "New Folder",
"parent": {
"id": "0"
}
}'
TypeScript Gen
await parentClient.folders.createFolder({
name: getUuid(),
parent: { id: '0' } satisfies CreateFolderRequestBodyParentField,
} satisfies CreateFolderRequestBody);
Python Gen
parent_client.folders.create_folder(get_uuid(), CreateFolderParent(id="0"))
.NET Gen
await parentClient.Folders.CreateFolderAsync(requestBody: new CreateFolderRequestBody(name: Utils.GetUUID(), parent: new CreateFolderRequestBodyParentField(id: "0")));
Java
BoxFolder parentFolder = new BoxFolder(api, "id");
BoxFolder.Info childFolderInfo = parentFolder.createFolder("Child Folder Name");
Python
subfolder = client.folder('0').create_subfolder('My Stuff')
print(f'Created subfolder with ID {subfolder.id}')
.NET
// Create a new folder in the user's root folder
var folderParams = new BoxFolderRequest()
{
Name = "New folder",
Parent = new BoxRequestEntity()
{
Id = "0"
}
};
BoxFolder folder = await client.FoldersManager.CreateAsync(folderParams);
Node
client.folders.create('0', 'New Folder')
.then(folder => {
/* folder -> {
type: 'folder',
id: '123456',
sequence_id: '0',
etag: '0',
name: 'New Folder',
created_at: '2012-12-12T10:53:43-08:00',
modified_at: '2012-12-12T11:15:04-08:00',
description: '',
size: 0,
path_collection:
{ total_count: 1,
entries:
[ { type: 'folder',
id: '0',
sequence_id: null,
etag: null,
name: 'All Files' } ] },
created_by:
{ type: 'user',
id: '22222',
name: 'Example User'
login: 'user@example.com' },
modified_by:
{ type: 'user',
id: '22222',
name: 'Example User',
login: 'user@example.com' },
owned_by:
{ type: 'user',
id: '22222',
name: 'Example User',
login: 'user@example.com' },
shared_link: null,
parent:
{ type: 'folder',
id: '0',
sequence_id: null,
etag: null,
name: 'All Files' },
item_status: 'active',
item_collection:
{ total_count: 0,
entries: [],
offset: 0,
limit: 100 } }
*/
});
iOS
client.folders.create(name: "New Folder", parentId: "22222") { (result: Result<Folder, BoxSDKError>) in
guard case let .success(folder) = result else {
print("Error creating folder")
return
}
print("Created folder \"\(folder.name)\" inside of folder \"\(folder.parent?.name)\"")
}