Creates a new folder. To create a folder in the root folder, use a parent folder id = "0".
curl https://api.box.com/2.0/folders \
-H "Authorization: Bearer BOX_ACCESS_TOKEN" \
-d '{"name":"Important Docs", "parent": {"id": "BOX_FOLDER_ID"}}' \
-X POST
integer li_rc
oleobject loo_Rest
integer li_Success
integer li_BTls
integer li_Port
integer li_BAutoReconnect
oleobject loo_Json
oleobject loo_SbRequestBody
oleobject loo_SbResponseBody
oleobject loo_JsonResponse
string ls_Type
string ls_Id
string ls_Sequence_id
string ls_Etag
string ls_Name
string ls_Created_at
string ls_Modified_at
string ls_Description
integer li_Size
integer li_Path_collectionTotal_count
string ls_Created_byType
string ls_Created_byId
string ls_Created_byName
string ls_Created_byLogin
string ls_Modified_byType
string ls_Modified_byId
string ls_Modified_byName
string ls_Modified_byLogin
integer li_Trashed_at
integer li_Purged_at
string ls_Content_created_at
string ls_Content_modified_at
string ls_Owned_byType
string ls_Owned_byId
string ls_Owned_byName
string ls_Owned_byLogin
integer li_Shared_link
integer li_Folder_upload_email
string ls_ParentType
string ls_ParentId
integer li_ParentSequence_id
integer li_ParentEtag
string ls_ParentName
string ls_Item_status
integer li_Item_collectionTotal_count
integer li_Item_collectionOffset
integer li_Item_collectionLimit
integer i
integer li_Count_i
integer li_Sequence_id_bool
integer li_Etag_bool
string ls_By
string ls_Direction
loo_Rest = create oleobject
li_rc = loo_Rest.ConnectToNewObject("Chilkat_9_5_0.Rest")
if li_rc < 0 then
destroy loo_Rest
MessageBox("Error","Connecting to COM object failed")
return
end if
// URL: https://api.box.com/2.0/folders
li_BTls = 1
li_Port = 443
li_BAutoReconnect = 1
li_Success = loo_Rest.Connect("api.box.com",li_Port,li_BTls,li_BAutoReconnect)
if li_Success <> 1 then
Write-Debug "ConnectFailReason: " + string(loo_Rest.ConnectFailReason)
Write-Debug loo_Rest.LastErrorText
destroy loo_Rest
return
end if
loo_Json = create oleobject
li_rc = loo_Json.ConnectToNewObject("Chilkat_9_5_0.JsonObject")
loo_Json.UpdateString("name","Important Docs")
loo_Json.UpdateString("parent.id","BOX_FOLDER_ID")
loo_Rest.AddHeader("Authorization","Bearer BOX_ACCESS_TOKEN")
loo_SbRequestBody = create oleobject
li_rc = loo_SbRequestBody.ConnectToNewObject("Chilkat_9_5_0.StringBuilder")
loo_Json.EmitSb(loo_SbRequestBody)
loo_SbResponseBody = create oleobject
li_rc = loo_SbResponseBody.ConnectToNewObject("Chilkat_9_5_0.StringBuilder")
li_Success = loo_Rest.FullRequestSb("POST","/2.0/folders",loo_SbRequestBody,loo_SbResponseBody)
if li_Success <> 1 then
Write-Debug loo_Rest.LastErrorText
destroy loo_Rest
destroy loo_Json
destroy loo_SbRequestBody
destroy loo_SbResponseBody
return
end if
loo_JsonResponse = create oleobject
li_rc = loo_JsonResponse.ConnectToNewObject("Chilkat_9_5_0.JsonObject")
loo_JsonResponse.LoadSb(loo_SbResponseBody)
ls_Type = loo_JsonResponse.StringOf("type")
ls_Id = loo_JsonResponse.StringOf("id")
ls_Sequence_id = loo_JsonResponse.StringOf("sequence_id")
ls_Etag = loo_JsonResponse.StringOf("etag")
ls_Name = loo_JsonResponse.StringOf("name")
ls_Created_at = loo_JsonResponse.StringOf("created_at")
ls_Modified_at = loo_JsonResponse.StringOf("modified_at")
ls_Description = loo_JsonResponse.StringOf("description")
li_Size = loo_JsonResponse.IntOf("size")
li_Path_collectionTotal_count = loo_JsonResponse.IntOf("path_collection.total_count")
ls_Created_byType = loo_JsonResponse.StringOf("created_by.type")
ls_Created_byId = loo_JsonResponse.StringOf("created_by.id")
ls_Created_byName = loo_JsonResponse.StringOf("created_by.name")
ls_Created_byLogin = loo_JsonResponse.StringOf("created_by.login")
ls_Modified_byType = loo_JsonResponse.StringOf("modified_by.type")
ls_Modified_byId = loo_JsonResponse.StringOf("modified_by.id")
ls_Modified_byName = loo_JsonResponse.StringOf("modified_by.name")
ls_Modified_byLogin = loo_JsonResponse.StringOf("modified_by.login")
li_Trashed_at = loo_JsonResponse.IsNullOf("trashed_at")
li_Purged_at = loo_JsonResponse.IsNullOf("purged_at")
ls_Content_created_at = loo_JsonResponse.StringOf("content_created_at")
ls_Content_modified_at = loo_JsonResponse.StringOf("content_modified_at")
ls_Owned_byType = loo_JsonResponse.StringOf("owned_by.type")
ls_Owned_byId = loo_JsonResponse.StringOf("owned_by.id")
ls_Owned_byName = loo_JsonResponse.StringOf("owned_by.name")
ls_Owned_byLogin = loo_JsonResponse.StringOf("owned_by.login")
li_Shared_link = loo_JsonResponse.IsNullOf("shared_link")
li_Folder_upload_email = loo_JsonResponse.IsNullOf("folder_upload_email")
ls_ParentType = loo_JsonResponse.StringOf("parent.type")
ls_ParentId = loo_JsonResponse.StringOf("parent.id")
li_ParentSequence_id = loo_JsonResponse.IsNullOf("parent.sequence_id")
li_ParentEtag = loo_JsonResponse.IsNullOf("parent.etag")
ls_ParentName = loo_JsonResponse.StringOf("parent.name")
ls_Item_status = loo_JsonResponse.StringOf("item_status")
li_Item_collectionTotal_count = loo_JsonResponse.IntOf("item_collection.total_count")
li_Item_collectionOffset = loo_JsonResponse.IntOf("item_collection.offset")
li_Item_collectionLimit = loo_JsonResponse.IntOf("item_collection.limit")
i = 0
li_Count_i = loo_JsonResponse.SizeOfArray("path_collection.entries")
do while i < li_Count_i
loo_JsonResponse.I = i
ls_Type = loo_JsonResponse.StringOf("path_collection.entries[i].type")
ls_Id = loo_JsonResponse.StringOf("path_collection.entries[i].id")
li_Sequence_id_bool = loo_JsonResponse.IsNullOf("path_collection.entries[i].sequence_id")
li_Etag_bool = loo_JsonResponse.IsNullOf("path_collection.entries[i].etag")
ls_Name = loo_JsonResponse.StringOf("path_collection.entries[i].name")
i = i + 1
loop
i = 0
li_Count_i = loo_JsonResponse.SizeOfArray("item_collection.entries")
do while i < li_Count_i
loo_JsonResponse.I = i
i = i + 1
loop
i = 0
li_Count_i = loo_JsonResponse.SizeOfArray("item_collection.order")
do while i < li_Count_i
loo_JsonResponse.I = i
ls_By = loo_JsonResponse.StringOf("item_collection.order[i].by")
ls_Direction = loo_JsonResponse.StringOf("item_collection.order[i].direction")
i = i + 1
loop
destroy loo_Rest
destroy loo_Json
destroy loo_SbRequestBody
destroy loo_SbResponseBody
destroy loo_JsonResponse
{
"type": "folder",
"id": "47885473705",
"sequence_id": "0",
"etag": "0",
"name": "Important Docs",
"created_at": "2018-03-16T06:54:57-07:00",
"modified_at": "2018-03-16T06:54:57-07: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": "2787704945",
"name": "chilkat",
"login": "AutomationUser_434741_3nmGYSS7o5@@boxdevedition.com"
},
"modified_by": {
"type": "user",
"id": "2787704945",
"name": "chilkat",
"login": "AutomationUser_434741_3nmGYSS7o5@@boxdevedition.com"
},
"trashed_at": null,
"purged_at": null,
"content_created_at": "2018-03-16T06:54:57-07:00",
"content_modified_at": "2018-03-16T06:54:57-07:00",
"owned_by": {
"type": "user",
"id": "2787704945",
"name": "chilkat",
"login": "AutomationUser_434741_3nmGYSS7o5@@boxdevedition.com"
},
"shared_link": null,
"folder_upload_email": 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,
"order": [
{
"by": "type",
"direction": "ASC"
},
{
"by": "name",
"direction": "ASC"
}
]
}
}