Retrieves a list of files for a particular team drive.
Use ChilkatAx-9.5.0-win32.pkg
Procedure Test
Handle hoRest
Boolean iSuccess
Variant vOauth2
Handle hoOauth2
Variant vSbJson
Handle hoSbJson
Handle hoJson
String sKind
Boolean iIncompleteSearch
Integer i
Integer iCount_i
String sId
String sName
String sMimeType
String sTeamDriveId
String sTemp1
Integer iTemp1
Get Create (RefClass(cComChilkatRest)) To hoRest
If (Not(IsComObjectCreated(hoRest))) Begin
Send CreateComObject of hoRest
End
// Provide a previously obtained OAuth2 access token.
Get Create (RefClass(cComChilkatOAuth2)) To hoOauth2
If (Not(IsComObjectCreated(hoOauth2))) Begin
Send CreateComObject of hoOauth2
End
Set ComAccessToken Of hoOauth2 To "OAUTH2_ACCESS_TOKEN"
Get pvComObject of hoOauth2 to vOauth2
Get ComSetAuthOAuth2 Of hoRest vOauth2 To iSuccess
Get ComConnect Of hoRest "www.googleapis.com" 443 True True To iSuccess
If (iSuccess <> True) Begin
Get ComLastErrorText Of hoRest To sTemp1
Showln sTemp1
Procedure_Return
End
Get ComAddQueryParam Of hoRest "teamDriveId" "0AEd3EhGff2SaUk9PVA" To iSuccess
Get ComAddQueryParam Of hoRest "includeTeamDriveItems" "true" To iSuccess
Get ComAddQueryParam Of hoRest "corpora" "teamDrive" To iSuccess
Get ComAddQueryParam Of hoRest "supportsTeamDrives" "true" To iSuccess
Get Create (RefClass(cComChilkatStringBuilder)) To hoSbJson
If (Not(IsComObjectCreated(hoSbJson))) Begin
Send CreateComObject of hoSbJson
End
Get pvComObject of hoSbJson to vSbJson
Get ComFullRequestNoBodySb Of hoRest "GET" "/drive/v3/files" vSbJson To iSuccess
If (iSuccess <> True) Begin
Get ComLastErrorText Of hoRest To sTemp1
Showln sTemp1
Procedure_Return
End
Get ComResponseStatusCode Of hoRest To iTemp1
If (iTemp1 <> 200) Begin
Get ComResponseStatusCode Of hoRest To iTemp1
Showln "Received error response code: " iTemp1
Showln "Response body:"
Get ComGetAsString Of hoSbJson To sTemp1
Showln sTemp1
Procedure_Return
End
Get Create (RefClass(cComChilkatJsonObject)) To hoJson
If (Not(IsComObjectCreated(hoJson))) Begin
Send CreateComObject of hoJson
End
Get pvComObject of hoSbJson to vSbJson
Get ComLoadSb Of hoJson vSbJson To iSuccess
// The following code parses the JSON response.
// A sample JSON response is shown below the sample code.
Get ComStringOf Of hoJson "kind" To sKind
Get ComBoolOf Of hoJson "incompleteSearch" To iIncompleteSearch
Move 0 To i
Get ComSizeOfArray Of hoJson "files" To iCount_i
While (i < iCount_i)
Set ComI Of hoJson To i
Get ComStringOf Of hoJson "files[i].kind" To sKind
Get ComStringOf Of hoJson "files[i].id" To sId
Get ComStringOf Of hoJson "files[i].name" To sName
Get ComStringOf Of hoJson "files[i].mimeType" To sMimeType
Get ComStringOf Of hoJson "files[i].teamDriveId" To sTeamDriveId
Move i + 1 To i
Loop
Showln "Example Completed."
End_Procedure
{
"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"
}
]
}