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.
IncludeFile "CkJsonObject.pb"
IncludeFile "CkStringBuilder.pb"
IncludeFile "CkRest.pb"
IncludeFile "CkOAuth2.pb"
Procedure ChilkatExample()
rest.i = CkRest::ckCreate()
If rest.i = 0
Debug "Failed to create object."
ProcedureReturn
EndIf
success.i
; Provide a previously obtained OAuth2 access token.
oauth2.i = CkOAuth2::ckCreate()
If oauth2.i = 0
Debug "Failed to create object."
ProcedureReturn
EndIf
CkOAuth2::setCkAccessToken(oauth2, "OAUTH2_ACCESS_TOKEN")
CkRest::ckSetAuthOAuth2(rest,oauth2)
success = CkRest::ckConnect(rest,"www.googleapis.com",443,1,1)
If success <> 1
Debug CkRest::ckLastErrorText(rest)
CkRest::ckDispose(rest)
CkOAuth2::ckDispose(oauth2)
ProcedureReturn
EndIf
CkRest::ckAddQueryParam(rest,"teamDriveId","0AEd3EhGff2SaUk9PVA")
CkRest::ckAddQueryParam(rest,"pageToken","13")
CkRest::ckAddQueryParam(rest,"includeTeamDriveItems","true")
CkRest::ckAddQueryParam(rest,"supportsTeamDrives","true")
sbJson.i = CkStringBuilder::ckCreate()
If sbJson.i = 0
Debug "Failed to create object."
ProcedureReturn
EndIf
success = CkRest::ckFullRequestNoBodySb(rest,"GET","/drive/v3/changes",sbJson)
If success <> 1
Debug CkRest::ckLastErrorText(rest)
CkRest::ckDispose(rest)
CkOAuth2::ckDispose(oauth2)
CkStringBuilder::ckDispose(sbJson)
ProcedureReturn
EndIf
If CkRest::ckResponseStatusCode(rest) <> 200
Debug "Received error response code: " + Str(CkRest::ckResponseStatusCode(rest))
Debug "Response body:"
Debug CkStringBuilder::ckGetAsString(sbJson)
CkRest::ckDispose(rest)
CkOAuth2::ckDispose(oauth2)
CkStringBuilder::ckDispose(sbJson)
ProcedureReturn
EndIf
json.i = CkJsonObject::ckCreate()
If json.i = 0
Debug "Failed to create object."
ProcedureReturn
EndIf
CkJsonObject::ckLoadSb(json,sbJson)
; The following code parses the JSON response.
; A sample JSON response is shown below the sample code.
kind.s
newStartPageToken.s
i.i
count_i.i
type.s
time.s
removed.i
fileId.s
fileKind.s
fileName.s
fileMimeType.s
fileTeamDriveId.s
kind = CkJsonObject::ckStringOf(json,"kind")
newStartPageToken = CkJsonObject::ckStringOf(json,"newStartPageToken")
i = 0
count_i = CkJsonObject::ckSizeOfArray(json,"changes")
While i < count_i
CkJsonObject::setCkI(json, i)
kind = CkJsonObject::ckStringOf(json,"changes[i].kind")
type = CkJsonObject::ckStringOf(json,"changes[i].type")
time = CkJsonObject::ckStringOf(json,"changes[i].time")
removed = CkJsonObject::ckBoolOf(json,"changes[i].removed")
fileId = CkJsonObject::ckStringOf(json,"changes[i].fileId")
fileKind = CkJsonObject::ckStringOf(json,"changes[i].file.kind")
fileId = CkJsonObject::ckStringOf(json,"changes[i].file.id")
fileName = CkJsonObject::ckStringOf(json,"changes[i].file.name")
fileMimeType = CkJsonObject::ckStringOf(json,"changes[i].file.mimeType")
fileTeamDriveId = CkJsonObject::ckStringOf(json,"changes[i].file.teamDriveId")
i = i + 1
Wend
Debug "Example Completed."
CkRest::ckDispose(rest)
CkOAuth2::ckDispose(oauth2)
CkStringBuilder::ckDispose(sbJson)
CkJsonObject::ckDispose(json)
ProcedureReturn
EndProcedure
{
"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"
}
}
]
}