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}"
#include <CkRestW.h>
#include <CkJsonObjectW.h>
#include <CkStringBuilderW.h>
void ChilkatSample(void)
{
CkRestW rest;
bool success;
// URL: https://api.dropboxapi.com/2/files/list_folder
bool bTls = true;
int port = 443;
bool bAutoReconnect = true;
success = rest.Connect(L"api.dropboxapi.com",port,bTls,bAutoReconnect);
if (success != true) {
wprintf(L"ConnectFailReason: %d\n",rest.get_ConnectFailReason());
wprintf(L"%s\n",rest.lastErrorText());
return;
}
// See the Online Tool for Generating JSON Creation Code
CkJsonObjectW json;
json.UpdateString(L"path",L"/Homework/math");
json.UpdateBool(L"recursive",false);
json.UpdateBool(L"include_media_info",false);
json.UpdateBool(L"include_deleted",false);
json.UpdateBool(L"include_has_explicit_shared_members",false);
json.UpdateBool(L"include_mounted_folders",true);
rest.AddHeader(L"Authorization",L"Bearer DROPBOX-ACCESS-TOKEN");
rest.AddHeader(L"Content-Type",L"application/json");
CkStringBuilderW sbRequestBody;
json.EmitSb(sbRequestBody);
CkStringBuilderW sbResponseBody;
success = rest.FullRequestSb(L"POST",L"/2/files/list_folder",sbRequestBody,sbResponseBody);
if (success != true) {
wprintf(L"%s\n",rest.lastErrorText());
return;
}
int respStatusCode = rest.get_ResponseStatusCode();
if (respStatusCode >= 400) {
wprintf(L"Response Status Code = %d\n",respStatusCode);
wprintf(L"Response Header:\n");
wprintf(L"%s\n",rest.responseHeader());
wprintf(L"Response Body:\n");
wprintf(L"%s\n",sbResponseBody.getAsString());
return;
}
CkJsonObjectW jsonResponse;
jsonResponse.LoadSb(sbResponseBody);
// See the Online Tool for Generating JSON Parse Code
int i;
int count_i;
const wchar_t *cursor = jsonResponse.stringOf(L"cursor");
bool has_more = jsonResponse.BoolOf(L"has_more");
i = 0;
count_i = jsonResponse.SizeOfArray(L"entries");
while (i < count_i) {
jsonResponse.put_I(i);
const wchar_t *Tag = jsonResponse.stringOf(L"entries[i].\".tag\"");
const wchar_t *name = jsonResponse.stringOf(L"entries[i].name");
const wchar_t *path_lower = jsonResponse.stringOf(L"entries[i].path_lower");
const wchar_t *path_display = jsonResponse.stringOf(L"entries[i].path_display");
const wchar_t *id = jsonResponse.stringOf(L"entries[i].id");
const wchar_t *client_modified = jsonResponse.stringOf(L"entries[i].client_modified");
const wchar_t *server_modified = jsonResponse.stringOf(L"entries[i].server_modified");
const wchar_t *rev = jsonResponse.stringOf(L"entries[i].rev");
int size = jsonResponse.IntOf(L"entries[i].size");
const wchar_t *content_hash = jsonResponse.stringOf(L"entries[i].content_hash");
i = i + 1;
}
}
{
"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
}