Lists the replies for a particular comment on a file. The file is specified by file ID. This example lists replies for comment (id="AAAABg7tSGw") on the file having id = "0B5drHSd5ZHwgc3RhcnRlcl9maWxlX2Rhc2hlclYw".
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, 'fields', 'replies'
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/0B5drHSd5ZHwgc3RhcnRlcl9maWxlX2Rhc2hlclYw/comments/AAAABg7tSGw/replies', 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 @i int
DECLARE @count_i int
DECLARE @kind nvarchar(4000)
DECLARE @id nvarchar(4000)
DECLARE @createdTime nvarchar(4000)
DECLARE @modifiedTime nvarchar(4000)
DECLARE @authorKind nvarchar(4000)
DECLARE @authorDisplayName nvarchar(4000)
DECLARE @authorPhotoLink nvarchar(4000)
DECLARE @authorMe int
DECLARE @htmlContent nvarchar(4000)
DECLARE @content nvarchar(4000)
DECLARE @deleted int
DECLARE @action nvarchar(4000)
SELECT @i = 0
EXEC sp_OAMethod @json, 'SizeOfArray', @count_i OUT, 'replies'
WHILE STR(@i) < STR(@count_i)
BEGIN
EXEC sp_OASetProperty @json, 'I', STR(@i)
EXEC sp_OAMethod @json, 'StringOf', @kind OUT, 'replies[i].kind'
EXEC sp_OAMethod @json, 'StringOf', @id OUT, 'replies[i].id'
EXEC sp_OAMethod @json, 'StringOf', @createdTime OUT, 'replies[i].createdTime'
EXEC sp_OAMethod @json, 'StringOf', @modifiedTime OUT, 'replies[i].modifiedTime'
EXEC sp_OAMethod @json, 'StringOf', @authorKind OUT, 'replies[i].author.kind'
EXEC sp_OAMethod @json, 'StringOf', @authorDisplayName OUT, 'replies[i].author.displayName'
EXEC sp_OAMethod @json, 'StringOf', @authorPhotoLink OUT, 'replies[i].author.photoLink'
EXEC sp_OAMethod @json, 'BoolOf', @authorMe OUT, 'replies[i].author.me'
EXEC sp_OAMethod @json, 'StringOf', @htmlContent OUT, 'replies[i].htmlContent'
EXEC sp_OAMethod @json, 'StringOf', @content OUT, 'replies[i].content'
EXEC sp_OAMethod @json, 'BoolOf', @deleted OUT, 'replies[i].deleted'
EXEC sp_OAMethod @json, 'StringOf', @action OUT, 'replies[i].action'
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
{
"replies": [
{
"kind": "drive#reply",
"id": "AAAABg76H9g",
"createdTime": "2017-11-13T18:24:12.782Z",
"modifiedTime": "2017-11-13T18:24:12.782Z",
"author": {
"kind": "drive#user",
"displayName": "Matt Fausey",
"photoLink": "//ssl.gstatic.com/s2/profiles/images/silhouette96.png",
"me": true
},
"htmlContent": "This is the first reply to a comment.",
"content": "This is the first reply to a comment.",
"deleted": false,
"action": "reopen"
},
{
"kind": "drive#reply",
"id": "AAAABg76H9k",
"createdTime": "2017-11-13T18:24:45.085Z",
"modifiedTime": "2017-11-13T18:24:45.085Z",
"author": {
"kind": "drive#user",
"displayName": "Matt Fausey",
"photoLink": "//ssl.gstatic.com/s2/profiles/images/silhouette96.png",
"me": true
},
"htmlContent": "This is the second reply to a comment.",
"content": "This is the second reply to a comment.",
"deleted": false,
"action": "resolve"
},
{
"kind": "drive#reply",
"id": "AAAABg76H9o",
"createdTime": "2017-11-13T18:25:11.828Z",
"modifiedTime": "2017-11-13T18:25:11.828Z",
"author": {
"kind": "drive#user",
"displayName": "Matt Fausey",
"photoLink": "//ssl.gstatic.com/s2/profiles/images/silhouette96.png",
"me": true
},
"htmlContent": "This is the third reply to a comment.",
"content": "This is the third reply to a comment.",
"deleted": false,
"action": "resolve"
}
]
}