PowerBuilder Box: Get Root Folder Info

Back to Index

Gets the folder info for the root folder of a Box.com account. The root folder of a box.com account always has an id = "0".

Documentation: https://developer.box.com/reference#get-folder-info

CURL Command

curl https://api.box.com/2.0/folders/0 \
-H "Authorization: Bearer BOX_ACCESS_TOKEN" \

PowerBuilder Example

integer li_rc
oleobject loo_Rest
integer li_Success
integer li_BTls
integer li_Port
integer li_BAutoReconnect
oleobject loo_SbResponseBody
oleobject loo_JsonResponse
string ls_Type
string ls_Id
integer li_Sequence_id
integer li_Etag
string ls_Name
integer li_Created_at
integer li_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
integer li_Content_created_at
integer li_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
integer li_Parent
string ls_Item_status
integer li_Item_collectionTotal_count
integer li_Item_collectionOffset
integer li_Item_collectionLimit
integer i
integer li_Count_i
string ls_File_versionType
string ls_File_versionId
string ls_File_versionSha1
string ls_Sequence_id_str
string ls_Etag_str
string ls_Sha1
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/0
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_Rest.AddHeader("Authorization","Bearer BOX_ACCESS_TOKEN")

loo_SbResponseBody = create oleobject
li_rc = loo_SbResponseBody.ConnectToNewObject("Chilkat_9_5_0.StringBuilder")

li_Success = loo_Rest.FullRequestNoBodySb("GET","/2.0/folders/0",loo_SbResponseBody)
if li_Success <> 1 then
    Write-Debug loo_Rest.LastErrorText
    destroy loo_Rest
    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")
li_Sequence_id = loo_JsonResponse.IsNullOf("sequence_id")
li_Etag = loo_JsonResponse.IsNullOf("etag")
ls_Name = loo_JsonResponse.StringOf("name")
li_Created_at = loo_JsonResponse.IsNullOf("created_at")
li_Modified_at = loo_JsonResponse.IsNullOf("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")
li_Content_created_at = loo_JsonResponse.IsNullOf("content_created_at")
li_Content_modified_at = loo_JsonResponse.IsNullOf("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")
li_Parent = loo_JsonResponse.IsNullOf("parent")
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
    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
    ls_Type = loo_JsonResponse.StringOf("item_collection.entries[i].type")
    ls_Id = loo_JsonResponse.StringOf("item_collection.entries[i].id")
    ls_File_versionType = loo_JsonResponse.StringOf("item_collection.entries[i].file_version.type")
    ls_File_versionId = loo_JsonResponse.StringOf("item_collection.entries[i].file_version.id")
    ls_File_versionSha1 = loo_JsonResponse.StringOf("item_collection.entries[i].file_version.sha1")
    ls_Sequence_id_str = loo_JsonResponse.StringOf("item_collection.entries[i].sequence_id")
    ls_Etag_str = loo_JsonResponse.StringOf("item_collection.entries[i].etag")
    ls_Sha1 = loo_JsonResponse.StringOf("item_collection.entries[i].sha1")
    ls_Name = loo_JsonResponse.StringOf("item_collection.entries[i].name")
    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_SbResponseBody
destroy loo_JsonResponse

Sample JSON Response Body

{
  "type": "folder",
  "id": "0",
  "sequence_id": null,
  "etag": null,
  "name": "All Files",
  "created_at": null,
  "modified_at": null,
  "description": "",
  "size": 826408,
  "path_collection": {
    "total_count": 0,
    "entries": [
    ]
  },
  "created_by": {
    "type": "user",
    "id": "",
    "name": "",
    "login": ""
  },
  "modified_by": {
    "type": "user",
    "id": "2787704945",
    "name": "chilkat",
    "login": "AutomationUser_434741_3nmGYSS7o5@@boxdevedition.com"
  },
  "trashed_at": null,
  "purged_at": null,
  "content_created_at": null,
  "content_modified_at": null,
  "owned_by": {
    "type": "user",
    "id": "2787704945",
    "name": "chilkat",
    "login": "AutomationUser_434741_3nmGYSS7o5@@boxdevedition.com"
  },
  "shared_link": null,
  "folder_upload_email": null,
  "parent": null,
  "item_status": "active",
  "item_collection": {
    "total_count": 2,
    "entries": [
      {
        "type": "file",
        "id": "246181882790",
        "file_version": {
          "type": "file_version",
          "id": "259636211878",
          "sha1": "c9d2492fb97f88a9b4d1e35f32a3410e95853f18"
        },
        "sequence_id": "0",
        "etag": "0",
        "sha1": "c9d2492fb97f88a9b4d1e35f32a3410e95853f18",
        "name": "hedgehogs.jpg"
      },
      {
        "type": "file",
        "id": "246167973161",
        "file_version": {
          "type": "file_version",
          "id": "259621592361",
          "sha1": "df7be9dc4f467187783aca68c7ce98e4df2172d0"
        },
        "sequence_id": "0",
        "etag": "0",
        "sha1": "df7be9dc4f467187783aca68c7ce98e4df2172d0",
        "name": "penguins.jpg"
      }
    ],
    "offset": 0,
    "limit": 100,
    "order": [
      {
        "by": "type",
        "direction": "ASC"
      },
      {
        "by": "name",
        "direction": "ASC"
      }
    ]
  }
}