Tcl 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" \

Tcl Example


load ./chilkat.dll

set rest [new_CkRest]

#  URL: https://api.box.com/2.0/folders/0
set bTls 1
set port 443
set bAutoReconnect 1
set success [CkRest_Connect $rest "api.box.com" $port $bTls $bAutoReconnect]
if {[expr $success != 1]} then {
    puts "ConnectFailReason: [CkRest_ConnectFailReason $rest]"
    puts [CkRest_lastErrorText $rest]
    delete_CkRest $rest
    exit
}

CkRest_AddHeader $rest "Authorization" "Bearer BOX_ACCESS_TOKEN"

set sbResponseBody [new_CkStringBuilder]

set success [CkRest_FullRequestNoBodySb $rest "GET" "/2.0/folders/0" $sbResponseBody]
if {[expr $success != 1]} then {
    puts [CkRest_lastErrorText $rest]
    delete_CkRest $rest
    delete_CkStringBuilder $sbResponseBody
    exit
}

set jsonResponse [new_CkJsonObject]

CkJsonObject_LoadSb $jsonResponse $sbResponseBody

set type [CkJsonObject_stringOf $jsonResponse "type"]
set id [CkJsonObject_stringOf $jsonResponse "id"]
set sequence_id [CkJsonObject_IsNullOf $jsonResponse "sequence_id"]
set etag [CkJsonObject_IsNullOf $jsonResponse "etag"]
set name [CkJsonObject_stringOf $jsonResponse "name"]
set created_at [CkJsonObject_IsNullOf $jsonResponse "created_at"]
set modified_at [CkJsonObject_IsNullOf $jsonResponse "modified_at"]
set description [CkJsonObject_stringOf $jsonResponse "description"]
set size [CkJsonObject_IntOf $jsonResponse "size"]
set path_collectionTotal_count [CkJsonObject_IntOf $jsonResponse "path_collection.total_count"]
set created_byType [CkJsonObject_stringOf $jsonResponse "created_by.type"]
set created_byId [CkJsonObject_stringOf $jsonResponse "created_by.id"]
set created_byName [CkJsonObject_stringOf $jsonResponse "created_by.name"]
set created_byLogin [CkJsonObject_stringOf $jsonResponse "created_by.login"]
set modified_byType [CkJsonObject_stringOf $jsonResponse "modified_by.type"]
set modified_byId [CkJsonObject_stringOf $jsonResponse "modified_by.id"]
set modified_byName [CkJsonObject_stringOf $jsonResponse "modified_by.name"]
set modified_byLogin [CkJsonObject_stringOf $jsonResponse "modified_by.login"]
set trashed_at [CkJsonObject_IsNullOf $jsonResponse "trashed_at"]
set purged_at [CkJsonObject_IsNullOf $jsonResponse "purged_at"]
set content_created_at [CkJsonObject_IsNullOf $jsonResponse "content_created_at"]
set content_modified_at [CkJsonObject_IsNullOf $jsonResponse "content_modified_at"]
set owned_byType [CkJsonObject_stringOf $jsonResponse "owned_by.type"]
set owned_byId [CkJsonObject_stringOf $jsonResponse "owned_by.id"]
set owned_byName [CkJsonObject_stringOf $jsonResponse "owned_by.name"]
set owned_byLogin [CkJsonObject_stringOf $jsonResponse "owned_by.login"]
set shared_link [CkJsonObject_IsNullOf $jsonResponse "shared_link"]
set folder_upload_email [CkJsonObject_IsNullOf $jsonResponse "folder_upload_email"]
set parent [CkJsonObject_IsNullOf $jsonResponse "parent"]
set item_status [CkJsonObject_stringOf $jsonResponse "item_status"]
set item_collectionTotal_count [CkJsonObject_IntOf $jsonResponse "item_collection.total_count"]
set item_collectionOffset [CkJsonObject_IntOf $jsonResponse "item_collection.offset"]
set item_collectionLimit [CkJsonObject_IntOf $jsonResponse "item_collection.limit"]
set i 0
set count_i [CkJsonObject_SizeOfArray $jsonResponse "path_collection.entries"]
while {[expr $i < $count_i]} {
    CkJsonObject_put_I $jsonResponse $i
    set i [expr $i + 1]
}
set i 0
set count_i [CkJsonObject_SizeOfArray $jsonResponse "item_collection.entries"]
while {[expr $i < $count_i]} {
    CkJsonObject_put_I $jsonResponse $i
    set type [CkJsonObject_stringOf $jsonResponse "item_collection.entries[i].type"]
    set id [CkJsonObject_stringOf $jsonResponse "item_collection.entries[i].id"]
    set file_versionType [CkJsonObject_stringOf $jsonResponse "item_collection.entries[i].file_version.type"]
    set file_versionId [CkJsonObject_stringOf $jsonResponse "item_collection.entries[i].file_version.id"]
    set file_versionSha1 [CkJsonObject_stringOf $jsonResponse "item_collection.entries[i].file_version.sha1"]
    set sequence_id_str [CkJsonObject_stringOf $jsonResponse "item_collection.entries[i].sequence_id"]
    set etag_str [CkJsonObject_stringOf $jsonResponse "item_collection.entries[i].etag"]
    set sha1 [CkJsonObject_stringOf $jsonResponse "item_collection.entries[i].sha1"]
    set name [CkJsonObject_stringOf $jsonResponse "item_collection.entries[i].name"]
    set i [expr $i + 1]
}
set i 0
set count_i [CkJsonObject_SizeOfArray $jsonResponse "item_collection.order"]
while {[expr $i < $count_i]} {
    CkJsonObject_put_I $jsonResponse $i
    set by [CkJsonObject_stringOf $jsonResponse "item_collection.order[i].by"]
    set direction [CkJsonObject_stringOf $jsonResponse "item_collection.order[i].direction"]
    set i [expr $i + 1]
}

delete_CkRest $rest
delete_CkStringBuilder $sbResponseBody
delete_CkJsonObject $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"
      }
    ]
  }
}