Gets all of the files, folders, or web links contained within a folder.
curl https://api.box.com/2.0/folders/BOX_FOLDER_ID/items?limit=2&offset=0 \
-H "Authorization: Bearer BOX_ACCESS_TOKEN"
Use ChilkatAx-9.5.0-win32.pkg
Procedure Test
Handle hoRest
Boolean iSuccess
Boolean iBTls
Integer iPort
Boolean iBAutoReconnect
Variant vSbResponseBody
Handle hoSbResponseBody
Handle hoJsonResponse
Integer iTotal_count
Integer iOffset
Integer iLimit
Integer i
Integer iCount_i
String sType
String sId
String sFile_versionType
String sFile_versionId
String sFile_versionSha1
String sSequence_id
String sEtag
String sSha1
String sName
String sBy
String sDirection
String sTemp1
Integer iTemp1
Get Create (RefClass(cComChilkatRest)) To hoRest
If (Not(IsComObjectCreated(hoRest))) Begin
Send CreateComObject of hoRest
End
// URL: https://api.box.com/2.0/folders/BOX_FOLDER_ID/items?limit=2&offset=0
Move True To iBTls
Move 443 To iPort
Move True To iBAutoReconnect
Get ComConnect Of hoRest "api.box.com" iPort iBTls iBAutoReconnect To iSuccess
If (iSuccess <> True) Begin
Get ComConnectFailReason Of hoRest To iTemp1
Showln "ConnectFailReason: " iTemp1
Get ComLastErrorText Of hoRest To sTemp1
Showln sTemp1
Procedure_Return
End
Get ComAddHeader Of hoRest "Authorization" "Bearer BOX_ACCESS_TOKEN" To iSuccess
Get Create (RefClass(cComChilkatStringBuilder)) To hoSbResponseBody
If (Not(IsComObjectCreated(hoSbResponseBody))) Begin
Send CreateComObject of hoSbResponseBody
End
Get pvComObject of hoSbResponseBody to vSbResponseBody
Get ComFullRequestNoBodySb Of hoRest "GET" "/2.0/folders/BOX_FOLDER_ID/items?limit=2&offset=0" vSbResponseBody To iSuccess
If (iSuccess <> True) Begin
Get ComLastErrorText Of hoRest To sTemp1
Showln sTemp1
Procedure_Return
End
Get Create (RefClass(cComChilkatJsonObject)) To hoJsonResponse
If (Not(IsComObjectCreated(hoJsonResponse))) Begin
Send CreateComObject of hoJsonResponse
End
Get pvComObject of hoSbResponseBody to vSbResponseBody
Get ComLoadSb Of hoJsonResponse vSbResponseBody To iSuccess
Get ComIntOf Of hoJsonResponse "total_count" To iTotal_count
Get ComIntOf Of hoJsonResponse "offset" To iOffset
Get ComIntOf Of hoJsonResponse "limit" To iLimit
Move 0 To i
Get ComSizeOfArray Of hoJsonResponse "entries" To iCount_i
While (i < iCount_i)
Set ComI Of hoJsonResponse To i
Get ComStringOf Of hoJsonResponse "entries[i].type" To sType
Get ComStringOf Of hoJsonResponse "entries[i].id" To sId
Get ComStringOf Of hoJsonResponse "entries[i].file_version.type" To sFile_versionType
Get ComStringOf Of hoJsonResponse "entries[i].file_version.id" To sFile_versionId
Get ComStringOf Of hoJsonResponse "entries[i].file_version.sha1" To sFile_versionSha1
Get ComStringOf Of hoJsonResponse "entries[i].sequence_id" To sSequence_id
Get ComStringOf Of hoJsonResponse "entries[i].etag" To sEtag
Get ComStringOf Of hoJsonResponse "entries[i].sha1" To sSha1
Get ComStringOf Of hoJsonResponse "entries[i].name" To sName
Move i + 1 To i
Loop
Move 0 To i
Get ComSizeOfArray Of hoJsonResponse "order" To iCount_i
While (i < iCount_i)
Set ComI Of hoJsonResponse To i
Get ComStringOf Of hoJsonResponse "order[i].by" To sBy
Get ComStringOf Of hoJsonResponse "order[i].direction" To sDirection
Move i + 1 To i
Loop
End_Procedure
{
"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": 2,
"order": [
{
"by": "type",
"direction": "ASC"
},
{
"by": "name",
"direction": "ASC"
}
]
}