Delete a Team Drive. This example deletes the Team Drive having id = 0ANKf-53y-eUWUk9PVA.
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
DECLARE @sbResponse int
EXEC @hr = sp_OACreate 'Chilkat_9_5_0.StringBuilder', @sbResponse OUT
EXEC sp_OAMethod @rest, 'FullRequestNoBodySb', @success OUT, 'DELETE', '/drive/v3/teamdrives/0ANKf-53y-eUWUk9PVA', STR(@sbResponse)
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 @sbResponse
RETURN
END
EXEC sp_OAGetProperty @rest, 'ResponseStatusCode', @iTmp0 OUT
IF @iTmp0 <> 204
BEGIN
EXEC sp_OAGetProperty @rest, 'ResponseStatusCode', @iTmp0 OUT
PRINT 'Received error response code: ' + @iTmp0
PRINT 'Response body:'
EXEC sp_OAMethod @sbResponse, 'GetAsString', @sTmp0 OUT
PRINT @sTmp0
EXEC @hr = sp_OADestroy @rest
EXEC @hr = sp_OADestroy @oauth2
EXEC @hr = sp_OADestroy @sbResponse
RETURN
END
PRINT 'Example Completed.'
EXEC @hr = sp_OADestroy @rest
EXEC @hr = sp_OADestroy @oauth2
EXEC @hr = sp_OADestroy @sbResponse
END
GO