List the permissions for a file by file id. (In this example the file id = 1R_70heIyzIAu1_u0prXbYcaIiJRVkgBl)
CREATE PROCEDURE ChilkatSample
AS
BEGIN
DECLARE @hr int
DECLARE @iTmp0 int
DECLARE @sTmp0 nvarchar(4000)
DECLARE @rest int
EXEC @hr = sp_OACreate 'Chilkat_9_5_0.Rest', @rest OUT
IF @hr <> 0
BEGIN
PRINT 'Failed to create ActiveX component'
RETURN
END
DECLARE @success int
-- Provide a previously obtained OAuth2 access token.
DECLARE @oauth2 int
EXEC @hr = sp_OACreate 'Chilkat_9_5_0.OAuth2', @oauth2 OUT
EXEC sp_OASetProperty @oauth2, 'AccessToken', 'OAUTH2_ACCESS_TOKEN'
EXEC sp_OAMethod @rest, 'SetAuthOAuth2', @success OUT, STR(@oauth2)
EXEC sp_OAMethod @rest, 'Connect', @success OUT, 'www.googleapis.com', 443, 1, 1
IF STR(@success) <> 1
BEGIN
EXEC sp_OAGetProperty @rest, 'LastErrorText', @sTmp0 OUT
PRINT @sTmp0
EXEC @hr = sp_OADestroy @rest
EXEC @hr = sp_OADestroy @oauth2
RETURN
END
EXEC sp_OAMethod @rest, 'AddQueryParam', @success OUT, 'includeTeamDriveItems', 'true'
EXEC sp_OAMethod @rest, 'AddQueryParam', @success OUT, 'supportsTeamDrives', 'true'
DECLARE @sbJson int
EXEC @hr = sp_OACreate 'Chilkat_9_5_0.StringBuilder', @sbJson OUT
EXEC sp_OAMethod @rest, 'FullRequestNoBodySb', @success OUT, 'GET', '/drive/v3/files/1R_70heIyzIAu1_u0prXbYcaIiJRVkgBl/permissions', STR(@sbJson)
IF STR(@success) <> 1
BEGIN
EXEC sp_OAGetProperty @rest, 'LastErrorText', @sTmp0 OUT
PRINT @sTmp0
EXEC @hr = sp_OADestroy @rest
EXEC @hr = sp_OADestroy @oauth2
EXEC @hr = sp_OADestroy @sbJson
RETURN
END
EXEC sp_OAGetProperty @rest, 'ResponseStatusCode', @iTmp0 OUT
IF @iTmp0 <> 200
BEGIN
EXEC sp_OAGetProperty @rest, 'ResponseStatusCode', @iTmp0 OUT
PRINT 'Received error response code: ' + @iTmp0
PRINT 'Response body:'
EXEC sp_OAMethod @sbJson, 'GetAsString', @sTmp0 OUT
PRINT @sTmp0
EXEC @hr = sp_OADestroy @rest
EXEC @hr = sp_OADestroy @oauth2
EXEC @hr = sp_OADestroy @sbJson
RETURN
END
DECLARE @json int
EXEC @hr = sp_OACreate 'Chilkat_9_5_0.JsonObject', @json OUT
EXEC sp_OAMethod @json, 'LoadSb', @success OUT, STR(@sbJson)
-- The following code parses the JSON response.
-- A sample JSON response is shown below the sample code.
DECLARE @kind nvarchar(4000)
DECLARE @i int
DECLARE @count_i int
DECLARE @id nvarchar(4000)
DECLARE @type nvarchar(4000)
DECLARE @role nvarchar(4000)
DECLARE @allowFileDiscovery int
EXEC sp_OAMethod @json, 'StringOf', @kind OUT, 'kind'
SELECT @i = 0
EXEC sp_OAMethod @json, 'SizeOfArray', @count_i OUT, 'permissions'
WHILE STR(@i) < STR(@count_i)
BEGIN
EXEC sp_OASetProperty @json, 'I', STR(@i)
EXEC sp_OAMethod @json, 'StringOf', @kind OUT, 'permissions[i].kind'
EXEC sp_OAMethod @json, 'StringOf', @id OUT, 'permissions[i].id'
EXEC sp_OAMethod @json, 'StringOf', @type OUT, 'permissions[i].type'
EXEC sp_OAMethod @json, 'StringOf', @role OUT, 'permissions[i].role'
EXEC sp_OAMethod @json, 'BoolOf', @allowFileDiscovery OUT, 'permissions[i].allowFileDiscovery'
SELECT @i = STR(@i) + 1
END
PRINT 'Example Completed.'
EXEC @hr = sp_OADestroy @rest
EXEC @hr = sp_OADestroy @oauth2
EXEC @hr = sp_OADestroy @sbJson
EXEC @hr = sp_OADestroy @json
END
GO
{
"kind": "drive#permissionList",
"permissions": [
{
"kind": "drive#permission",
"id": "07604395918166943595k",
"type": "domain",
"role": "reader",
"allowFileDiscovery": false
},
{
"kind": "drive#permission",
"id": "05909037819814716957",
"type": "user",
"role": "organizer"
},
{
"kind": "drive#permission",
"id": "13254573739200948291",
"type": "user",
"role": "organizer"
}
]
}