Retrieves a list of files for a particular team drive.
#include <CkRestW.h>
#include <CkOAuth2W.h>
#include <CkStringBuilderW.h>
#include <CkJsonObjectW.h>
void ChilkatSample(void)
{
CkRestW rest;
bool success;
// Provide a previously obtained OAuth2 access token.
CkOAuth2W oauth2;
oauth2.put_AccessToken(L"OAUTH2_ACCESS_TOKEN");
rest.SetAuthOAuth2(oauth2);
success = rest.Connect(L"www.googleapis.com",443,true,true);
if (success != true) {
wprintf(L"%s\n",rest.lastErrorText());
return;
}
rest.AddQueryParam(L"teamDriveId",L"0AEd3EhGff2SaUk9PVA");
rest.AddQueryParam(L"includeTeamDriveItems",L"true");
rest.AddQueryParam(L"corpora",L"teamDrive");
rest.AddQueryParam(L"supportsTeamDrives",L"true");
CkStringBuilderW sbJson;
success = rest.FullRequestNoBodySb(L"GET",L"/drive/v3/files",sbJson);
if (success != true) {
wprintf(L"%s\n",rest.lastErrorText());
return;
}
if (rest.get_ResponseStatusCode() != 200) {
wprintf(L"Received error response code: %d\n",rest.get_ResponseStatusCode());
wprintf(L"Response body:\n");
wprintf(L"%s\n",sbJson.getAsString());
return;
}
CkJsonObjectW json;
json.LoadSb(sbJson);
// The following code parses the JSON response.
// A sample JSON response is shown below the sample code.
const wchar_t *kind = 0;
bool incompleteSearch;
int i;
int count_i;
const wchar_t *id = 0;
const wchar_t *name = 0;
const wchar_t *mimeType = 0;
const wchar_t *teamDriveId = 0;
kind = json.stringOf(L"kind");
incompleteSearch = json.BoolOf(L"incompleteSearch");
i = 0;
count_i = json.SizeOfArray(L"files");
while (i < count_i) {
json.put_I(i);
kind = json.stringOf(L"files[i].kind");
id = json.stringOf(L"files[i].id");
name = json.stringOf(L"files[i].name");
mimeType = json.stringOf(L"files[i].mimeType");
teamDriveId = json.stringOf(L"files[i].teamDriveId");
i = i + 1;
}
wprintf(L"Example Completed.\n");
}
{
"kind": "drive#fileList",
"incompleteSearch": false,
"files": [
{
"kind": "drive#file",
"id": "18UpPSa-c_OPNi2CXY05gkpjIzNAJyd4q",
"name": "hedgehogs.jpg",
"mimeType": "image/jpeg",
"teamDriveId": "0AEd3EhGff2SaUk9PVA"
},
{
"kind": "drive#file",
"id": "1R_70heIyzIAu1_u0prXbYcaIiJRVkgBl",
"name": "penguins.jpg",
"mimeType": "image/jpeg",
"teamDriveId": "0AEd3EhGff2SaUk9PVA"
},
{
"kind": "drive#file",
"id": "16MsxSRSz6ISRx1D_PXyA5Sj6aNFSEd4e",
"name": "seahorse.jpg",
"mimeType": "image/jpeg",
"teamDriveId": "0AEd3EhGff2SaUk9PVA"
},
{
"kind": "drive#file",
"id": "1lT4TbeSSMtxgB2MmwE7-5i7vQaxhr6Ze",
"name": "starfish2.jpg",
"mimeType": "image/jpeg",
"teamDriveId": "0AEd3EhGff2SaUk9PVA"
},
{
"kind": "drive#file",
"id": "1PVtx4SJB0n2GDcaJAbi_mSlQwXltYsx3",
"name": "test",
"mimeType": "application/vnd.google-apps.folder",
"teamDriveId": "0AEd3EhGff2SaUk9PVA"
}
]
}