Unicode C++ Google Drive: Get Starting pageToken for Listing Future Changes

Back to Index

Gets the starting pageToken for listing future changes.

Documentation: https://developers.google.com/drive/v3/reference/changes/getStartPageToken


#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"supportsTeamDrives",L"true");

    CkStringBuilderW sbJson;
    success = rest.FullRequestNoBodySb(L"GET",L"/drive/v3/changes/startPageToken",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;
    const wchar_t *startPageToken = 0;

    kind = json.stringOf(L"kind");
    startPageToken = json.stringOf(L"startPageToken");

    wprintf(L"Example Completed.\n");
    }

Sample JSON Response Body

{
  "kind": "drive#startPageToken",
  "startPageToken": "13"
}