Used to create a copy of a folder in another folder. The original version of the folder will not be altered. The a response status code of 202 is expected for success.
curl https://api.box.com/2.0/folders/FOLDER_ID/copy \
-H "Authorization: Bearer BOX_ACCESS_TOKEN" \
-d '{"parent": {"id" : DESTINATION_FOLDER_ID}}' \
-X POST
#include <C_CkRestW.h>
#include <C_CkJsonObjectW.h>
#include <C_CkStringBuilderW.h>
void ChilkatSample(void)
{
HCkRestW rest;
BOOL success;
BOOL bTls;
int port;
BOOL bAutoReconnect;
HCkJsonObjectW json;
HCkStringBuilderW sbRequestBody;
HCkStringBuilderW sbResponseBody;
HCkJsonObjectW jsonResponse;
const wchar_t *type;
const wchar_t *id;
const wchar_t *sequence_id;
const wchar_t *etag;
const wchar_t *name;
const wchar_t *created_at;
const wchar_t *modified_at;
const wchar_t *description;
int size;
int path_collectionTotal_count;
const wchar_t *created_byType;
const wchar_t *created_byId;
const wchar_t *created_byName;
const wchar_t *created_byLogin;
const wchar_t *modified_byType;
const wchar_t *modified_byId;
const wchar_t *modified_byName;
const wchar_t *modified_byLogin;
const wchar_t *owned_byType;
const wchar_t *owned_byId;
const wchar_t *owned_byName;
const wchar_t *owned_byLogin;
const wchar_t *shared_linkUrl;
BOOL shared_linkDownload_url;
BOOL shared_linkVanity_url;
BOOL shared_linkIs_password_enabled;
BOOL shared_linkUnshared_at;
int shared_linkDownload_count;
int shared_linkPreview_count;
const wchar_t *shared_linkAccess;
BOOL shared_linkPermissionsCan_download;
BOOL shared_linkPermissionsCan_preview;
const wchar_t *folder_upload_emailAccess;
const wchar_t *folder_upload_emailEmail;
const wchar_t *parentType;
const wchar_t *parentId;
BOOL parentSequence_id;
BOOL parentEtag;
const wchar_t *parentName;
const wchar_t *item_status;
int item_collectionTotal_count;
int item_collectionOffset;
int item_collectionLimit;
int i;
int count_i;
BOOL sequence_id_bool;
BOOL etag_bool;
const wchar_t *sha1;
rest = CkRestW_Create();
// URL: https://api.box.com/2.0/folders/FOLDER_ID/copy
bTls = TRUE;
port = 443;
bAutoReconnect = TRUE;
success = CkRestW_Connect(rest,L"api.box.com",port,bTls,bAutoReconnect);
if (success != TRUE) {
wprintf(L"ConnectFailReason: %d\n",CkRestW_getConnectFailReason(rest));
wprintf(L"%s\n",CkRestW_lastErrorText(rest));
CkRestW_Dispose(rest);
return;
}
json = CkJsonObjectW_Create();
CkJsonObjectW_UpdateNumber(json,L"parent.id",L"DESTINATION_FOLDER_ID");
CkRestW_AddHeader(rest,L"Authorization",L"Bearer BOX_ACCESS_TOKEN");
sbRequestBody = CkStringBuilderW_Create();
CkJsonObjectW_EmitSb(json,sbRequestBody);
sbResponseBody = CkStringBuilderW_Create();
success = CkRestW_FullRequestSb(rest,L"POST",L"/2.0/folders/FOLDER_ID/copy",sbRequestBody,sbResponseBody);
if (success != TRUE) {
wprintf(L"%s\n",CkRestW_lastErrorText(rest));
CkRestW_Dispose(rest);
CkJsonObjectW_Dispose(json);
CkStringBuilderW_Dispose(sbRequestBody);
CkStringBuilderW_Dispose(sbResponseBody);
return;
}
jsonResponse = CkJsonObjectW_Create();
CkJsonObjectW_LoadSb(jsonResponse,sbResponseBody);
type = CkJsonObjectW_stringOf(jsonResponse,L"type");
id = CkJsonObjectW_stringOf(jsonResponse,L"id");
sequence_id = CkJsonObjectW_stringOf(jsonResponse,L"sequence_id");
etag = CkJsonObjectW_stringOf(jsonResponse,L"etag");
name = CkJsonObjectW_stringOf(jsonResponse,L"name");
created_at = CkJsonObjectW_stringOf(jsonResponse,L"created_at");
modified_at = CkJsonObjectW_stringOf(jsonResponse,L"modified_at");
description = CkJsonObjectW_stringOf(jsonResponse,L"description");
size = CkJsonObjectW_IntOf(jsonResponse,L"size");
path_collectionTotal_count = CkJsonObjectW_IntOf(jsonResponse,L"path_collection.total_count");
created_byType = CkJsonObjectW_stringOf(jsonResponse,L"created_by.type");
created_byId = CkJsonObjectW_stringOf(jsonResponse,L"created_by.id");
created_byName = CkJsonObjectW_stringOf(jsonResponse,L"created_by.name");
created_byLogin = CkJsonObjectW_stringOf(jsonResponse,L"created_by.login");
modified_byType = CkJsonObjectW_stringOf(jsonResponse,L"modified_by.type");
modified_byId = CkJsonObjectW_stringOf(jsonResponse,L"modified_by.id");
modified_byName = CkJsonObjectW_stringOf(jsonResponse,L"modified_by.name");
modified_byLogin = CkJsonObjectW_stringOf(jsonResponse,L"modified_by.login");
owned_byType = CkJsonObjectW_stringOf(jsonResponse,L"owned_by.type");
owned_byId = CkJsonObjectW_stringOf(jsonResponse,L"owned_by.id");
owned_byName = CkJsonObjectW_stringOf(jsonResponse,L"owned_by.name");
owned_byLogin = CkJsonObjectW_stringOf(jsonResponse,L"owned_by.login");
shared_linkUrl = CkJsonObjectW_stringOf(jsonResponse,L"shared_link.url");
shared_linkDownload_url = CkJsonObjectW_IsNullOf(jsonResponse,L"shared_link.download_url");
shared_linkVanity_url = CkJsonObjectW_IsNullOf(jsonResponse,L"shared_link.vanity_url");
shared_linkIs_password_enabled = CkJsonObjectW_BoolOf(jsonResponse,L"shared_link.is_password_enabled");
shared_linkUnshared_at = CkJsonObjectW_IsNullOf(jsonResponse,L"shared_link.unshared_at");
shared_linkDownload_count = CkJsonObjectW_IntOf(jsonResponse,L"shared_link.download_count");
shared_linkPreview_count = CkJsonObjectW_IntOf(jsonResponse,L"shared_link.preview_count");
shared_linkAccess = CkJsonObjectW_stringOf(jsonResponse,L"shared_link.access");
shared_linkPermissionsCan_download = CkJsonObjectW_BoolOf(jsonResponse,L"shared_link.permissions.can_download");
shared_linkPermissionsCan_preview = CkJsonObjectW_BoolOf(jsonResponse,L"shared_link.permissions.can_preview");
folder_upload_emailAccess = CkJsonObjectW_stringOf(jsonResponse,L"folder_upload_email.access");
folder_upload_emailEmail = CkJsonObjectW_stringOf(jsonResponse,L"folder_upload_email.email");
parentType = CkJsonObjectW_stringOf(jsonResponse,L"parent.type");
parentId = CkJsonObjectW_stringOf(jsonResponse,L"parent.id");
parentSequence_id = CkJsonObjectW_IsNullOf(jsonResponse,L"parent.sequence_id");
parentEtag = CkJsonObjectW_IsNullOf(jsonResponse,L"parent.etag");
parentName = CkJsonObjectW_stringOf(jsonResponse,L"parent.name");
item_status = CkJsonObjectW_stringOf(jsonResponse,L"item_status");
item_collectionTotal_count = CkJsonObjectW_IntOf(jsonResponse,L"item_collection.total_count");
item_collectionOffset = CkJsonObjectW_IntOf(jsonResponse,L"item_collection.offset");
item_collectionLimit = CkJsonObjectW_IntOf(jsonResponse,L"item_collection.limit");
i = 0;
count_i = CkJsonObjectW_SizeOfArray(jsonResponse,L"path_collection.entries");
while (i < count_i) {
CkJsonObjectW_putI(jsonResponse,i);
type = CkJsonObjectW_stringOf(jsonResponse,L"path_collection.entries[i].type");
id = CkJsonObjectW_stringOf(jsonResponse,L"path_collection.entries[i].id");
sequence_id_bool = CkJsonObjectW_IsNullOf(jsonResponse,L"path_collection.entries[i].sequence_id");
etag_bool = CkJsonObjectW_IsNullOf(jsonResponse,L"path_collection.entries[i].etag");
name = CkJsonObjectW_stringOf(jsonResponse,L"path_collection.entries[i].name");
i = i + 1;
}
i = 0;
count_i = CkJsonObjectW_SizeOfArray(jsonResponse,L"item_collection.entries");
while (i < count_i) {
CkJsonObjectW_putI(jsonResponse,i);
type = CkJsonObjectW_stringOf(jsonResponse,L"item_collection.entries[i].type");
id = CkJsonObjectW_stringOf(jsonResponse,L"item_collection.entries[i].id");
sequence_id = CkJsonObjectW_stringOf(jsonResponse,L"item_collection.entries[i].sequence_id");
etag = CkJsonObjectW_stringOf(jsonResponse,L"item_collection.entries[i].etag");
sha1 = CkJsonObjectW_stringOf(jsonResponse,L"item_collection.entries[i].sha1");
name = CkJsonObjectW_stringOf(jsonResponse,L"item_collection.entries[i].name");
i = i + 1;
}
CkRestW_Dispose(rest);
CkJsonObjectW_Dispose(json);
CkStringBuilderW_Dispose(sbRequestBody);
CkStringBuilderW_Dispose(sbResponseBody);
CkJsonObjectW_Dispose(jsonResponse);
}
{
"type": "folder",
"id": "11446498",
"sequence_id": "1",
"etag": "1",
"name": "Pictures",
"created_at": "2012-12-12T10:53:43-08:00",
"modified_at": "2012-12-12T11:15:04-08:00",
"description": "Some pictures I took",
"size": 629644,
"path_collection": {
"total_count": 1,
"entries": [
{
"type": "folder",
"id": "0",
"sequence_id": null,
"etag": null,
"name": "All Files"
}
]
},
"created_by": {
"type": "user",
"id": "17738362",
"name": "sean rose",
"login": "sean@box.com"
},
"modified_by": {
"type": "user",
"id": "17738362",
"name": "sean rose",
"login": "sean@box.com"
},
"owned_by": {
"type": "user",
"id": "17738362",
"name": "sean rose",
"login": "sean@box.com"
},
"shared_link": {
"url": "https://www.box.com/s/vspke7y05sb214wjokpk",
"download_url": null,
"vanity_url": null,
"is_password_enabled": false,
"unshared_at": null,
"download_count": 0,
"preview_count": 0,
"access": "open",
"permissions": {
"can_download": true,
"can_preview": true
}
},
"folder_upload_email": {
"access": "open",
"email": "upload.Picture.k13sdz1@u.box.com"
},
"parent": {
"type": "folder",
"id": "0",
"sequence_id": null,
"etag": null,
"name": "All Files"
},
"item_status": "active",
"item_collection": {
"total_count": 1,
"entries": [
{
"type": "file",
"id": "5000948880",
"sequence_id": "3",
"etag": "3",
"sha1": "134b65991ed521fcfe4724b7d814ab8ded5185dc",
"name": "tigers.jpeg"
}
],
"offset": 0,
"limit": 100
}
}