Starts returning the contents of a folder. If the result's ListFolderResult.has_more field is true, call list_folder/continue with the returned ListFolderResult.cursor to retrieve more entries.
curl -X POST https://api.dropboxapi.com/2/files/list_folder \
--header "Authorization: Bearer DROPBOX-ACCESS-TOKEN" \
--header "Content-Type: application/json" \
--data "{\"path\": \"/Homework/math\",\"recursive\": false,\"include_media_info\": false,\"include_deleted\": false,\"include_has_explicit_shared_members\": false,\"include_mounted_folders\": true}"
Use ChilkatAx-9.5.0-win32.pkg
Procedure Test
Handle hoRest
Boolean iSuccess
Boolean iBTls
Integer iPort
Boolean iBAutoReconnect
Handle hoJson
Variant vSbRequestBody
Handle hoSbRequestBody
Variant vSbResponseBody
Handle hoSbResponseBody
Integer iRespStatusCode
Response Handle hoJsonResponse
Integer i
Integer iCount_i
String sCursor
Boolean iHas_more
String sTag
String sName
String sPath_lower
String sPath_display
String sId
String sClient_modified
String sServer_modified
String sRev
Integer iSize
String sContent_hash
String sTemp1
Integer iTemp1
Get Create (RefClass(cComChilkatRest)) To hoRest
If (Not(IsComObjectCreated(hoRest))) Begin
Send CreateComObject of hoRest
End
// URL: https://api.dropboxapi.com/2/files/list_folder
Move True To iBTls
Move 443 To iPort
Move True To iBAutoReconnect
Get ComConnect Of hoRest "api.dropboxapi.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
// See the Online Tool for Generating JSON Creation Code
Get Create (RefClass(cComChilkatJsonObject)) To hoJson
If (Not(IsComObjectCreated(hoJson))) Begin
Send CreateComObject of hoJson
End
Get ComUpdateString Of hoJson "path" "/Homework/math" To iSuccess
Get ComUpdateBool Of hoJson "recursive" False To iSuccess
Get ComUpdateBool Of hoJson "include_media_info" False To iSuccess
Get ComUpdateBool Of hoJson "include_deleted" False To iSuccess
Get ComUpdateBool Of hoJson "include_has_explicit_shared_members" False To iSuccess
Get ComUpdateBool Of hoJson "include_mounted_folders" True To iSuccess
Get ComAddHeader Of hoRest "Authorization" "Bearer DROPBOX-ACCESS-TOKEN" To iSuccess
Get ComAddHeader Of hoRest "Content-Type" "application/json" To iSuccess
Get Create (RefClass(cComChilkatStringBuilder)) To hoSbRequestBody
If (Not(IsComObjectCreated(hoSbRequestBody))) Begin
Send CreateComObject of hoSbRequestBody
End
Get pvComObject of hoSbRequestBody to vSbRequestBody
Get ComEmitSb Of hoJson vSbRequestBody To iSuccess
Get Create (RefClass(cComChilkatStringBuilder)) To hoSbResponseBody
If (Not(IsComObjectCreated(hoSbResponseBody))) Begin
Send CreateComObject of hoSbResponseBody
End
Get pvComObject of hoSbRequestBody to vSbRequestBody
Get pvComObject of hoSbResponseBody to vSbResponseBody
Get ComFullRequestSb Of hoRest "POST" "/2/files/list_folder" vSbRequestBody vSbResponseBody To iSuccess
If (iSuccess <> True) Begin
Get ComLastErrorText Of hoRest To sTemp1
Showln sTemp1
Procedure_Return
End
Get ComResponseStatusCode Of hoRest To iRespStatusCode
If (iRespStatusCode >= 400) Begin
Showln "Response Status Code = " iRespStatusCode
Showln "Response Header:"
Get ComResponseHeader Of hoRest To sTemp1
Showln sTemp1
Showln "Response Body:"
Get ComGetAsString Of hoSbResponseBody 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
// See the Online Tool for Generating JSON Parse Code
Get ComStringOf Of hoJsonResponse "cursor" To sCursor
Get ComBoolOf Of hoJsonResponse "has_more" To iHas_more
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].".tag"' To sTag
Get ComStringOf Of hoJsonResponse "entries[i].name" To sName
Get ComStringOf Of hoJsonResponse "entries[i].path_lower" To sPath_lower
Get ComStringOf Of hoJsonResponse "entries[i].path_display" To sPath_display
Get ComStringOf Of hoJsonResponse "entries[i].id" To sId
Get ComStringOf Of hoJsonResponse "entries[i].client_modified" To sClient_modified
Get ComStringOf Of hoJsonResponse "entries[i].server_modified" To sServer_modified
Get ComStringOf Of hoJsonResponse "entries[i].rev" To sRev
Get ComIntOf Of hoJsonResponse "entries[i].size" To iSize
Get ComStringOf Of hoJsonResponse "entries[i].content_hash" To sContent_hash
Move i + 1 To i
Loop
End_Procedure
{
"entries": [
{
".tag": "file",
"name": "Matrices.txt",
"path_lower": "/homework/math/matrices.txt",
"path_display": "/Homework/math/Matrices.txt",
"id": "id:qk7WwvROeSAAAAAAAAAAAQ",
"client_modified": "2016-06-02T20:41:02Z",
"server_modified": "2016-06-02T20:41:03Z",
"rev": "5482db15f",
"size": 6,
"content_hash": "5a3c776e2631edabe2ba710ac72301b3aeca821ba4f7d36b56cc6050ea6c2ba8"
},
{
".tag": "file",
"name": "Document.docx",
"path_lower": "/homework/math/document.docx",
"path_display": "/Homework/math/Document.docx",
"id": "id:JSXYsxHo1hAAAAAAAAAABw",
"client_modified": "2018-10-22T21:59:23Z",
"server_modified": "2018-10-22T21:59:23Z",
"rev": "10482db15f",
"size": 11009,
"content_hash": "ab9c1887a653a8f42e4401425ac02839e1f76533e1d44ac8d0605d870a16c25d"
}
],
"cursor": "AAHnmmjY1IztwebFmkByuZ_Vgzz-tSYXYE3KhdkUxBfETpGjPqTBz7ZzBj1G7zkPPVanKCt0FtzqXjDQ2ggQKYZTiL4mJ346fRelmP049QjN5CZzeMHbD_lSFqA96Br36vR9YLg40VAHu42TcCG38MbUPOCKa-wdguu5C1JsgYvIaXIcjRMCfbxz98JdYhhefmu0pjoxtgtCstOrmp_pXIng",
"has_more": false
}