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.
LOCAL loRest
LOCAL lnSuccess
LOCAL loOauth2
LOCAL loSbJson
LOCAL loJson
LOCAL lcKind
LOCAL lcNewStartPageToken
LOCAL i
LOCAL lnCount_i
LOCAL lcType
LOCAL lcTime
LOCAL lnRemoved
LOCAL lcFileId
LOCAL lcFileKind
LOCAL lcFileName
LOCAL lcFileMimeType
LOCAL lcFileTeamDriveId
loRest = CreateObject('Chilkat_9_5_0.Rest')
* Provide a previously obtained OAuth2 access token.
loOauth2 = CreateObject('Chilkat_9_5_0.OAuth2')
loOauth2.AccessToken = "OAUTH2_ACCESS_TOKEN"
loRest.SetAuthOAuth2(loOauth2)
lnSuccess = loRest.Connect("www.googleapis.com",443,1,1)
IF (lnSuccess <> 1) THEN
? loRest.LastErrorText
RELEASE loRest
RELEASE loOauth2
CANCEL
ENDIF
loRest.AddQueryParam("teamDriveId","0AEd3EhGff2SaUk9PVA")
loRest.AddQueryParam("pageToken","13")
loRest.AddQueryParam("includeTeamDriveItems","true")
loRest.AddQueryParam("supportsTeamDrives","true")
loSbJson = CreateObject('Chilkat_9_5_0.StringBuilder')
lnSuccess = loRest.FullRequestNoBodySb("GET","/drive/v3/changes",loSbJson)
IF (lnSuccess <> 1) THEN
? loRest.LastErrorText
RELEASE loRest
RELEASE loOauth2
RELEASE loSbJson
CANCEL
ENDIF
IF (loRest.ResponseStatusCode <> 200) THEN
? "Received error response code: " + STR(loRest.ResponseStatusCode)
? "Response body:"
? loSbJson.GetAsString()
RELEASE loRest
RELEASE loOauth2
RELEASE loSbJson
CANCEL
ENDIF
loJson = CreateObject('Chilkat_9_5_0.JsonObject')
loJson.LoadSb(loSbJson)
* The following code parses the JSON response.
* A sample JSON response is shown below the sample code.
lcKind = loJson.StringOf("kind")
lcNewStartPageToken = loJson.StringOf("newStartPageToken")
i = 0
lnCount_i = loJson.SizeOfArray("changes")
DO WHILE i < lnCount_i
loJson.I = i
lcKind = loJson.StringOf("changes[i].kind")
lcType = loJson.StringOf("changes[i].type")
lcTime = loJson.StringOf("changes[i].time")
lnRemoved = loJson.BoolOf("changes[i].removed")
lcFileId = loJson.StringOf("changes[i].fileId")
lcFileKind = loJson.StringOf("changes[i].file.kind")
lcFileId = loJson.StringOf("changes[i].file.id")
lcFileName = loJson.StringOf("changes[i].file.name")
lcFileMimeType = loJson.StringOf("changes[i].file.mimeType")
lcFileTeamDriveId = loJson.StringOf("changes[i].file.teamDriveId")
i = i + 1
ENDDO
? "Example Completed."
RELEASE loRest
RELEASE loOauth2
RELEASE loSbJson
RELEASE loJson
{
"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"
}
}
]
}