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
CREATE PROCEDURE ChilkatSample
AS
BEGIN
DECLARE @hr int
DECLARE @iTmp0 int
DECLARE @sTmp0 nvarchar(4000)
DECLARE @rest int
EXEC @hr = sp_OACreate 'Chilkat_9_5_0.Rest', @rest OUT
IF @hr <> 0
BEGIN
PRINT 'Failed to create ActiveX component'
RETURN
END
DECLARE @success int
-- URL: https://api.box.com/2.0/folders/FOLDER_ID/copy
DECLARE @bTls int
SELECT @bTls = 1
DECLARE @port int
SELECT @port = 443
DECLARE @bAutoReconnect int
SELECT @bAutoReconnect = 1
EXEC sp_OAMethod @rest, 'Connect', @success OUT, 'api.box.com', STR(@port), STR(@bTls), STR(@bAutoReconnect)
IF STR(@success) <> 1
BEGIN
EXEC sp_OAGetProperty @rest, 'ConnectFailReason', @iTmp0 OUT
PRINT 'ConnectFailReason: ' + @iTmp0
EXEC sp_OAGetProperty @rest, 'LastErrorText', @sTmp0 OUT
PRINT @sTmp0
EXEC @hr = sp_OADestroy @rest
RETURN
END
DECLARE @json int
EXEC @hr = sp_OACreate 'Chilkat_9_5_0.JsonObject', @json OUT
EXEC sp_OAMethod @json, 'UpdateNumber', @success OUT, 'parent.id', 'DESTINATION_FOLDER_ID'
EXEC sp_OAMethod @rest, 'AddHeader', @success OUT, 'Authorization', 'Bearer BOX_ACCESS_TOKEN'
DECLARE @sbRequestBody int
EXEC @hr = sp_OACreate 'Chilkat_9_5_0.StringBuilder', @sbRequestBody OUT
EXEC sp_OAMethod @json, 'EmitSb', @success OUT, STR(@sbRequestBody)
DECLARE @sbResponseBody int
EXEC @hr = sp_OACreate 'Chilkat_9_5_0.StringBuilder', @sbResponseBody OUT
EXEC sp_OAMethod @rest, 'FullRequestSb', @success OUT, 'POST', '/2.0/folders/FOLDER_ID/copy', STR(@sbRequestBody), STR(@sbResponseBody)
IF STR(@success) <> 1
BEGIN
EXEC sp_OAGetProperty @rest, 'LastErrorText', @sTmp0 OUT
PRINT @sTmp0
EXEC @hr = sp_OADestroy @rest
EXEC @hr = sp_OADestroy @json
EXEC @hr = sp_OADestroy @sbRequestBody
EXEC @hr = sp_OADestroy @sbResponseBody
RETURN
END
DECLARE @jsonResponse int
EXEC @hr = sp_OACreate 'Chilkat_9_5_0.JsonObject', @jsonResponse OUT
EXEC sp_OAMethod @jsonResponse, 'LoadSb', @success OUT, STR(@sbResponseBody)
DECLARE @type nvarchar(4000)
DECLARE @id nvarchar(4000)
DECLARE @sequence_id nvarchar(4000)
DECLARE @etag nvarchar(4000)
DECLARE @name nvarchar(4000)
DECLARE @created_at nvarchar(4000)
DECLARE @modified_at nvarchar(4000)
DECLARE @description nvarchar(4000)
DECLARE @size int
DECLARE @path_collectionTotal_count int
DECLARE @created_byType nvarchar(4000)
DECLARE @created_byId nvarchar(4000)
DECLARE @created_byName nvarchar(4000)
DECLARE @created_byLogin nvarchar(4000)
DECLARE @modified_byType nvarchar(4000)
DECLARE @modified_byId nvarchar(4000)
DECLARE @modified_byName nvarchar(4000)
DECLARE @modified_byLogin nvarchar(4000)
DECLARE @owned_byType nvarchar(4000)
DECLARE @owned_byId nvarchar(4000)
DECLARE @owned_byName nvarchar(4000)
DECLARE @owned_byLogin nvarchar(4000)
DECLARE @shared_linkUrl nvarchar(4000)
DECLARE @shared_linkDownload_url int
DECLARE @shared_linkVanity_url int
DECLARE @shared_linkIs_password_enabled int
DECLARE @shared_linkUnshared_at int
DECLARE @shared_linkDownload_count int
DECLARE @shared_linkPreview_count int
DECLARE @shared_linkAccess nvarchar(4000)
DECLARE @shared_linkPermissionsCan_download int
DECLARE @shared_linkPermissionsCan_preview int
DECLARE @folder_upload_emailAccess nvarchar(4000)
DECLARE @folder_upload_emailEmail nvarchar(4000)
DECLARE @parentType nvarchar(4000)
DECLARE @parentId nvarchar(4000)
DECLARE @parentSequence_id int
DECLARE @parentEtag int
DECLARE @parentName nvarchar(4000)
DECLARE @item_status nvarchar(4000)
DECLARE @item_collectionTotal_count int
DECLARE @item_collectionOffset int
DECLARE @item_collectionLimit int
DECLARE @i int
DECLARE @count_i int
DECLARE @sequence_id_bool int
DECLARE @etag_bool int
DECLARE @sha1 nvarchar(4000)
EXEC sp_OAMethod @jsonResponse, 'StringOf', @type OUT, 'type'
EXEC sp_OAMethod @jsonResponse, 'StringOf', @id OUT, 'id'
EXEC sp_OAMethod @jsonResponse, 'StringOf', @sequence_id OUT, 'sequence_id'
EXEC sp_OAMethod @jsonResponse, 'StringOf', @etag OUT, 'etag'
EXEC sp_OAMethod @jsonResponse, 'StringOf', @name OUT, 'name'
EXEC sp_OAMethod @jsonResponse, 'StringOf', @created_at OUT, 'created_at'
EXEC sp_OAMethod @jsonResponse, 'StringOf', @modified_at OUT, 'modified_at'
EXEC sp_OAMethod @jsonResponse, 'StringOf', @description OUT, 'description'
EXEC sp_OAMethod @jsonResponse, 'IntOf', @size OUT, 'size'
EXEC sp_OAMethod @jsonResponse, 'IntOf', @path_collectionTotal_count OUT, 'path_collection.total_count'
EXEC sp_OAMethod @jsonResponse, 'StringOf', @created_byType OUT, 'created_by.type'
EXEC sp_OAMethod @jsonResponse, 'StringOf', @created_byId OUT, 'created_by.id'
EXEC sp_OAMethod @jsonResponse, 'StringOf', @created_byName OUT, 'created_by.name'
EXEC sp_OAMethod @jsonResponse, 'StringOf', @created_byLogin OUT, 'created_by.login'
EXEC sp_OAMethod @jsonResponse, 'StringOf', @modified_byType OUT, 'modified_by.type'
EXEC sp_OAMethod @jsonResponse, 'StringOf', @modified_byId OUT, 'modified_by.id'
EXEC sp_OAMethod @jsonResponse, 'StringOf', @modified_byName OUT, 'modified_by.name'
EXEC sp_OAMethod @jsonResponse, 'StringOf', @modified_byLogin OUT, 'modified_by.login'
EXEC sp_OAMethod @jsonResponse, 'StringOf', @owned_byType OUT, 'owned_by.type'
EXEC sp_OAMethod @jsonResponse, 'StringOf', @owned_byId OUT, 'owned_by.id'
EXEC sp_OAMethod @jsonResponse, 'StringOf', @owned_byName OUT, 'owned_by.name'
EXEC sp_OAMethod @jsonResponse, 'StringOf', @owned_byLogin OUT, 'owned_by.login'
EXEC sp_OAMethod @jsonResponse, 'StringOf', @shared_linkUrl OUT, 'shared_link.url'
EXEC sp_OAMethod @jsonResponse, 'IsNullOf', @shared_linkDownload_url OUT, 'shared_link.download_url'
EXEC sp_OAMethod @jsonResponse, 'IsNullOf', @shared_linkVanity_url OUT, 'shared_link.vanity_url'
EXEC sp_OAMethod @jsonResponse, 'BoolOf', @shared_linkIs_password_enabled OUT, 'shared_link.is_password_enabled'
EXEC sp_OAMethod @jsonResponse, 'IsNullOf', @shared_linkUnshared_at OUT, 'shared_link.unshared_at'
EXEC sp_OAMethod @jsonResponse, 'IntOf', @shared_linkDownload_count OUT, 'shared_link.download_count'
EXEC sp_OAMethod @jsonResponse, 'IntOf', @shared_linkPreview_count OUT, 'shared_link.preview_count'
EXEC sp_OAMethod @jsonResponse, 'StringOf', @shared_linkAccess OUT, 'shared_link.access'
EXEC sp_OAMethod @jsonResponse, 'BoolOf', @shared_linkPermissionsCan_download OUT, 'shared_link.permissions.can_download'
EXEC sp_OAMethod @jsonResponse, 'BoolOf', @shared_linkPermissionsCan_preview OUT, 'shared_link.permissions.can_preview'
EXEC sp_OAMethod @jsonResponse, 'StringOf', @folder_upload_emailAccess OUT, 'folder_upload_email.access'
EXEC sp_OAMethod @jsonResponse, 'StringOf', @folder_upload_emailEmail OUT, 'folder_upload_email.email'
EXEC sp_OAMethod @jsonResponse, 'StringOf', @parentType OUT, 'parent.type'
EXEC sp_OAMethod @jsonResponse, 'StringOf', @parentId OUT, 'parent.id'
EXEC sp_OAMethod @jsonResponse, 'IsNullOf', @parentSequence_id OUT, 'parent.sequence_id'
EXEC sp_OAMethod @jsonResponse, 'IsNullOf', @parentEtag OUT, 'parent.etag'
EXEC sp_OAMethod @jsonResponse, 'StringOf', @parentName OUT, 'parent.name'
EXEC sp_OAMethod @jsonResponse, 'StringOf', @item_status OUT, 'item_status'
EXEC sp_OAMethod @jsonResponse, 'IntOf', @item_collectionTotal_count OUT, 'item_collection.total_count'
EXEC sp_OAMethod @jsonResponse, 'IntOf', @item_collectionOffset OUT, 'item_collection.offset'
EXEC sp_OAMethod @jsonResponse, 'IntOf', @item_collectionLimit OUT, 'item_collection.limit'
SELECT @i = 0
EXEC sp_OAMethod @jsonResponse, 'SizeOfArray', @count_i OUT, 'path_collection.entries'
WHILE STR(@i) < STR(@count_i)
BEGIN
EXEC sp_OASetProperty @jsonResponse, 'I', STR(@i)
EXEC sp_OAMethod @jsonResponse, 'StringOf', @type OUT, 'path_collection.entries[i].type'
EXEC sp_OAMethod @jsonResponse, 'StringOf', @id OUT, 'path_collection.entries[i].id'
EXEC sp_OAMethod @jsonResponse, 'IsNullOf', @sequence_id_bool OUT, 'path_collection.entries[i].sequence_id'
EXEC sp_OAMethod @jsonResponse, 'IsNullOf', @etag_bool OUT, 'path_collection.entries[i].etag'
EXEC sp_OAMethod @jsonResponse, 'StringOf', @name OUT, 'path_collection.entries[i].name'
SELECT @i = STR(@i) + 1
END
SELECT @i = 0
EXEC sp_OAMethod @jsonResponse, 'SizeOfArray', @count_i OUT, 'item_collection.entries'
WHILE STR(@i) < STR(@count_i)
BEGIN
EXEC sp_OASetProperty @jsonResponse, 'I', STR(@i)
EXEC sp_OAMethod @jsonResponse, 'StringOf', @type OUT, 'item_collection.entries[i].type'
EXEC sp_OAMethod @jsonResponse, 'StringOf', @id OUT, 'item_collection.entries[i].id'
EXEC sp_OAMethod @jsonResponse, 'StringOf', @sequence_id OUT, 'item_collection.entries[i].sequence_id'
EXEC sp_OAMethod @jsonResponse, 'StringOf', @etag OUT, 'item_collection.entries[i].etag'
EXEC sp_OAMethod @jsonResponse, 'StringOf', @sha1 OUT, 'item_collection.entries[i].sha1'
EXEC sp_OAMethod @jsonResponse, 'StringOf', @name OUT, 'item_collection.entries[i].name'
SELECT @i = STR(@i) + 1
END
EXEC @hr = sp_OADestroy @rest
EXEC @hr = sp_OADestroy @json
EXEC @hr = sp_OADestroy @sbRequestBody
EXEC @hr = sp_OADestroy @sbResponseBody
EXEC @hr = sp_OADestroy @jsonResponse
END
GO
{
"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
}
}