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
LOCAL loRest
LOCAL lnSuccess
LOCAL lnBTls
LOCAL lnPort
LOCAL lnBAutoReconnect
LOCAL loJson
LOCAL loSbRequestBody
LOCAL loSbResponseBody
LOCAL loJsonResponse
LOCAL lcType
LOCAL lcId
LOCAL lcSequence_id
LOCAL lcEtag
LOCAL lcName
LOCAL lcCreated_at
LOCAL lcModified_at
LOCAL lcDescription
LOCAL lnSize
LOCAL lnPath_collectionTotal_count
LOCAL lcCreated_byType
LOCAL lcCreated_byId
LOCAL lcCreated_byName
LOCAL lcCreated_byLogin
LOCAL lcModified_byType
LOCAL lcModified_byId
LOCAL lcModified_byName
LOCAL lcModified_byLogin
LOCAL lcOwned_byType
LOCAL lcOwned_byId
LOCAL lcOwned_byName
LOCAL lcOwned_byLogin
LOCAL lcShared_linkUrl
LOCAL lnShared_linkDownload_url
LOCAL lnShared_linkVanity_url
LOCAL lnShared_linkIs_password_enabled
LOCAL lnShared_linkUnshared_at
LOCAL lnShared_linkDownload_count
LOCAL lnShared_linkPreview_count
LOCAL lcShared_linkAccess
LOCAL lnShared_linkPermissionsCan_download
LOCAL lnShared_linkPermissionsCan_preview
LOCAL lcFolder_upload_emailAccess
LOCAL lcFolder_upload_emailEmail
LOCAL lcParentType
LOCAL lcParentId
LOCAL lnParentSequence_id
LOCAL lnParentEtag
LOCAL lcParentName
LOCAL lcItem_status
LOCAL lnItem_collectionTotal_count
LOCAL lnItem_collectionOffset
LOCAL lnItem_collectionLimit
LOCAL i
LOCAL lnCount_i
LOCAL lnSequence_id_bool
LOCAL lnEtag_bool
LOCAL lcSha1
loRest = CreateObject('Chilkat_9_5_0.Rest')
* URL: https://api.box.com/2.0/folders/FOLDER_ID/copy
lnBTls = 1
lnPort = 443
lnBAutoReconnect = 1
lnSuccess = loRest.Connect("api.box.com",lnPort,lnBTls,lnBAutoReconnect)
IF (lnSuccess <> 1) THEN
? "ConnectFailReason: " + STR(loRest.ConnectFailReason)
? loRest.LastErrorText
RELEASE loRest
CANCEL
ENDIF
loJson = CreateObject('Chilkat_9_5_0.JsonObject')
loJson.UpdateNumber("parent.id","DESTINATION_FOLDER_ID")
loRest.AddHeader("Authorization","Bearer BOX_ACCESS_TOKEN")
loSbRequestBody = CreateObject('Chilkat_9_5_0.StringBuilder')
loJson.EmitSb(loSbRequestBody)
loSbResponseBody = CreateObject('Chilkat_9_5_0.StringBuilder')
lnSuccess = loRest.FullRequestSb("POST","/2.0/folders/FOLDER_ID/copy",loSbRequestBody,loSbResponseBody)
IF (lnSuccess <> 1) THEN
? loRest.LastErrorText
RELEASE loRest
RELEASE loJson
RELEASE loSbRequestBody
RELEASE loSbResponseBody
CANCEL
ENDIF
loJsonResponse = CreateObject('Chilkat_9_5_0.JsonObject')
loJsonResponse.LoadSb(loSbResponseBody)
lcType = loJsonResponse.StringOf("type")
lcId = loJsonResponse.StringOf("id")
lcSequence_id = loJsonResponse.StringOf("sequence_id")
lcEtag = loJsonResponse.StringOf("etag")
lcName = loJsonResponse.StringOf("name")
lcCreated_at = loJsonResponse.StringOf("created_at")
lcModified_at = loJsonResponse.StringOf("modified_at")
lcDescription = loJsonResponse.StringOf("description")
lnSize = loJsonResponse.IntOf("size")
lnPath_collectionTotal_count = loJsonResponse.IntOf("path_collection.total_count")
lcCreated_byType = loJsonResponse.StringOf("created_by.type")
lcCreated_byId = loJsonResponse.StringOf("created_by.id")
lcCreated_byName = loJsonResponse.StringOf("created_by.name")
lcCreated_byLogin = loJsonResponse.StringOf("created_by.login")
lcModified_byType = loJsonResponse.StringOf("modified_by.type")
lcModified_byId = loJsonResponse.StringOf("modified_by.id")
lcModified_byName = loJsonResponse.StringOf("modified_by.name")
lcModified_byLogin = loJsonResponse.StringOf("modified_by.login")
lcOwned_byType = loJsonResponse.StringOf("owned_by.type")
lcOwned_byId = loJsonResponse.StringOf("owned_by.id")
lcOwned_byName = loJsonResponse.StringOf("owned_by.name")
lcOwned_byLogin = loJsonResponse.StringOf("owned_by.login")
lcShared_linkUrl = loJsonResponse.StringOf("shared_link.url")
lnShared_linkDownload_url = loJsonResponse.IsNullOf("shared_link.download_url")
lnShared_linkVanity_url = loJsonResponse.IsNullOf("shared_link.vanity_url")
lnShared_linkIs_password_enabled = loJsonResponse.BoolOf("shared_link.is_password_enabled")
lnShared_linkUnshared_at = loJsonResponse.IsNullOf("shared_link.unshared_at")
lnShared_linkDownload_count = loJsonResponse.IntOf("shared_link.download_count")
lnShared_linkPreview_count = loJsonResponse.IntOf("shared_link.preview_count")
lcShared_linkAccess = loJsonResponse.StringOf("shared_link.access")
lnShared_linkPermissionsCan_download = loJsonResponse.BoolOf("shared_link.permissions.can_download")
lnShared_linkPermissionsCan_preview = loJsonResponse.BoolOf("shared_link.permissions.can_preview")
lcFolder_upload_emailAccess = loJsonResponse.StringOf("folder_upload_email.access")
lcFolder_upload_emailEmail = loJsonResponse.StringOf("folder_upload_email.email")
lcParentType = loJsonResponse.StringOf("parent.type")
lcParentId = loJsonResponse.StringOf("parent.id")
lnParentSequence_id = loJsonResponse.IsNullOf("parent.sequence_id")
lnParentEtag = loJsonResponse.IsNullOf("parent.etag")
lcParentName = loJsonResponse.StringOf("parent.name")
lcItem_status = loJsonResponse.StringOf("item_status")
lnItem_collectionTotal_count = loJsonResponse.IntOf("item_collection.total_count")
lnItem_collectionOffset = loJsonResponse.IntOf("item_collection.offset")
lnItem_collectionLimit = loJsonResponse.IntOf("item_collection.limit")
i = 0
lnCount_i = loJsonResponse.SizeOfArray("path_collection.entries")
DO WHILE i < lnCount_i
loJsonResponse.I = i
lcType = loJsonResponse.StringOf("path_collection.entries[i].type")
lcId = loJsonResponse.StringOf("path_collection.entries[i].id")
lnSequence_id_bool = loJsonResponse.IsNullOf("path_collection.entries[i].sequence_id")
lnEtag_bool = loJsonResponse.IsNullOf("path_collection.entries[i].etag")
lcName = loJsonResponse.StringOf("path_collection.entries[i].name")
i = i + 1
ENDDO
i = 0
lnCount_i = loJsonResponse.SizeOfArray("item_collection.entries")
DO WHILE i < lnCount_i
loJsonResponse.I = i
lcType = loJsonResponse.StringOf("item_collection.entries[i].type")
lcId = loJsonResponse.StringOf("item_collection.entries[i].id")
lcSequence_id = loJsonResponse.StringOf("item_collection.entries[i].sequence_id")
lcEtag = loJsonResponse.StringOf("item_collection.entries[i].etag")
lcSha1 = loJsonResponse.StringOf("item_collection.entries[i].sha1")
lcName = loJsonResponse.StringOf("item_collection.entries[i].name")
i = i + 1
ENDDO
RELEASE loRest
RELEASE loJson
RELEASE loSbRequestBody
RELEASE loSbResponseBody
RELEASE loJsonResponse
{
"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
}
}