Download a list of changes to a teamdrive. This example lists the changes for the team drive having id = "0AEd3EhGff2SaUk9PVA". The "pageToken" is obtained from a previous call to /drive/v3/changes/startPageToken or from the "nextPageToken" member of the previous call to list changes.
#include <C_CkRestW.h>
#include <C_CkOAuth2W.h>
#include <C_CkStringBuilderW.h>
#include <C_CkJsonObjectW.h>
void ChilkatSample(void)
{
HCkRestW rest;
BOOL success;
HCkOAuth2W oauth2;
HCkStringBuilderW sbJson;
HCkJsonObjectW json;
const wchar_t *kind;
const wchar_t *newStartPageToken;
int i;
int count_i;
const wchar_t *type;
const wchar_t *time;
BOOL removed;
const wchar_t *fileId;
const wchar_t *fileKind;
const wchar_t *fileName;
const wchar_t *fileMimeType;
const wchar_t *fileTeamDriveId;
rest = CkRestW_Create();
// Provide a previously obtained OAuth2 access token.
oauth2 = CkOAuth2W_Create();
CkOAuth2W_putAccessToken(oauth2,L"OAUTH2_ACCESS_TOKEN");
CkRestW_SetAuthOAuth2(rest,oauth2);
success = CkRestW_Connect(rest,L"www.googleapis.com",443,TRUE,TRUE);
if (success != TRUE) {
wprintf(L"%s\n",CkRestW_lastErrorText(rest));
CkRestW_Dispose(rest);
CkOAuth2W_Dispose(oauth2);
return;
}
CkRestW_AddQueryParam(rest,L"teamDriveId",L"0AEd3EhGff2SaUk9PVA");
CkRestW_AddQueryParam(rest,L"pageToken",L"13");
CkRestW_AddQueryParam(rest,L"includeTeamDriveItems",L"true");
CkRestW_AddQueryParam(rest,L"supportsTeamDrives",L"true");
sbJson = CkStringBuilderW_Create();
success = CkRestW_FullRequestNoBodySb(rest,L"GET",L"/drive/v3/changes",sbJson);
if (success != TRUE) {
wprintf(L"%s\n",CkRestW_lastErrorText(rest));
CkRestW_Dispose(rest);
CkOAuth2W_Dispose(oauth2);
CkStringBuilderW_Dispose(sbJson);
return;
}
if (CkRestW_getResponseStatusCode(rest) != 200) {
wprintf(L"Received error response code: %d\n",CkRestW_getResponseStatusCode(rest));
wprintf(L"Response body:\n");
wprintf(L"%s\n",CkStringBuilderW_getAsString(sbJson));
CkRestW_Dispose(rest);
CkOAuth2W_Dispose(oauth2);
CkStringBuilderW_Dispose(sbJson);
return;
}
json = CkJsonObjectW_Create();
CkJsonObjectW_LoadSb(json,sbJson);
// The following code parses the JSON response.
// A sample JSON response is shown below the sample code.
kind = CkJsonObjectW_stringOf(json,L"kind");
newStartPageToken = CkJsonObjectW_stringOf(json,L"newStartPageToken");
i = 0;
count_i = CkJsonObjectW_SizeOfArray(json,L"changes");
while (i < count_i) {
CkJsonObjectW_putI(json,i);
kind = CkJsonObjectW_stringOf(json,L"changes[i].kind");
type = CkJsonObjectW_stringOf(json,L"changes[i].type");
time = CkJsonObjectW_stringOf(json,L"changes[i].time");
removed = CkJsonObjectW_BoolOf(json,L"changes[i].removed");
fileId = CkJsonObjectW_stringOf(json,L"changes[i].fileId");
fileKind = CkJsonObjectW_stringOf(json,L"changes[i].file.kind");
fileId = CkJsonObjectW_stringOf(json,L"changes[i].file.id");
fileName = CkJsonObjectW_stringOf(json,L"changes[i].file.name");
fileMimeType = CkJsonObjectW_stringOf(json,L"changes[i].file.mimeType");
fileTeamDriveId = CkJsonObjectW_stringOf(json,L"changes[i].file.teamDriveId");
i = i + 1;
}
wprintf(L"Example Completed.\n");
CkRestW_Dispose(rest);
CkOAuth2W_Dispose(oauth2);
CkStringBuilderW_Dispose(sbJson);
CkJsonObjectW_Dispose(json);
}
{
"kind": "drive#changeList",
"newStartPageToken": "16",
"changes": [
{
"kind": "drive#change",
"type": "file",
"time": "2017-11-13T17:04:47.470Z",
"removed": false,
"fileId": "1lT4TbeSSMtxgB2MmwE7-5i7vQaxhr6Ze",
"file": {
"kind": "drive#file",
"id": "1lT4TbeSSMtxgB2MmwE7-5i7vQaxhr6Ze",
"name": "starfish2.jpg",
"mimeType": "image/jpeg",
"teamDriveId": "0AEd3EhGff2SaUk9PVA"
}
},
{
"kind": "drive#change",
"type": "file",
"time": "2017-11-13T17:05:01.095Z",
"removed": false,
"fileId": "16MsxSRSz6ISRx1D_PXyA5Sj6aNFSEd4e",
"file": {
"kind": "drive#file",
"id": "16MsxSRSz6ISRx1D_PXyA5Sj6aNFSEd4e",
"name": "seahorse.jpg",
"mimeType": "image/jpeg",
"teamDriveId": "0AEd3EhGff2SaUk9PVA"
}
}
]
}