Lists the comment on a file. The file is specified by file ID. This example lists comments 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', 'comments'
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', 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 @resolved int
DECLARE @j int
DECLARE @count_j int
DECLARE @action nvarchar(4000)
SELECT @i = 0
EXEC sp_OAMethod @json, 'SizeOfArray', @count_i OUT, 'comments'
WHILE STR(@i) < STR(@count_i)
BEGIN
EXEC sp_OASetProperty @json, 'I', STR(@i)
EXEC sp_OAMethod @json, 'StringOf', @kind OUT, 'comments[i].kind'
EXEC sp_OAMethod @json, 'StringOf', @id OUT, 'comments[i].id'
EXEC sp_OAMethod @json, 'StringOf', @createdTime OUT, 'comments[i].createdTime'
EXEC sp_OAMethod @json, 'StringOf', @modifiedTime OUT, 'comments[i].modifiedTime'
EXEC sp_OAMethod @json, 'StringOf', @authorKind OUT, 'comments[i].author.kind'
EXEC sp_OAMethod @json, 'StringOf', @authorDisplayName OUT, 'comments[i].author.displayName'
EXEC sp_OAMethod @json, 'StringOf', @authorPhotoLink OUT, 'comments[i].author.photoLink'
EXEC sp_OAMethod @json, 'BoolOf', @authorMe OUT, 'comments[i].author.me'
EXEC sp_OAMethod @json, 'StringOf', @htmlContent OUT, 'comments[i].htmlContent'
EXEC sp_OAMethod @json, 'StringOf', @content OUT, 'comments[i].content'
EXEC sp_OAMethod @json, 'BoolOf', @deleted OUT, 'comments[i].deleted'
EXEC sp_OAMethod @json, 'BoolOf', @resolved OUT, 'comments[i].resolved'
SELECT @j = 0
EXEC sp_OAMethod @json, 'SizeOfArray', @count_j OUT, 'comments[i].replies'
WHILE STR(@j) < STR(@count_j)
BEGIN
EXEC sp_OASetProperty @json, 'J', STR(@j)
EXEC sp_OAMethod @json, 'StringOf', @kind OUT, 'comments[i].replies[j].kind'
EXEC sp_OAMethod @json, 'StringOf', @id OUT, 'comments[i].replies[j].id'
EXEC sp_OAMethod @json, 'StringOf', @createdTime OUT, 'comments[i].replies[j].createdTime'
EXEC sp_OAMethod @json, 'StringOf', @modifiedTime OUT, 'comments[i].replies[j].modifiedTime'
EXEC sp_OAMethod @json, 'StringOf', @authorKind OUT, 'comments[i].replies[j].author.kind'
EXEC sp_OAMethod @json, 'StringOf', @authorDisplayName OUT, 'comments[i].replies[j].author.displayName'
EXEC sp_OAMethod @json, 'StringOf', @authorPhotoLink OUT, 'comments[i].replies[j].author.photoLink'
EXEC sp_OAMethod @json, 'BoolOf', @authorMe OUT, 'comments[i].replies[j].author.me'
EXEC sp_OAMethod @json, 'StringOf', @htmlContent OUT, 'comments[i].replies[j].htmlContent'
EXEC sp_OAMethod @json, 'StringOf', @content OUT, 'comments[i].replies[j].content'
EXEC sp_OAMethod @json, 'BoolOf', @deleted OUT, 'comments[i].replies[j].deleted'
EXEC sp_OAMethod @json, 'StringOf', @action OUT, 'comments[i].replies[j].action'
SELECT @j = STR(@j) + 1
END
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
{
"comments": [
{
"kind": "drive#comment",
"id": "AAAABg7vWfw",
"createdTime": "2017-11-13T17:51:57.906Z",
"modifiedTime": "2017-11-13T17:51:57.906Z",
"author": {
"kind": "drive#user",
"displayName": "Matt Fausey",
"photoLink": "//ssl.gstatic.com/s2/profiles/images/silhouette96.png",
"me": true
},
"htmlContent": "This is the 2nd test comment about this file...",
"content": "This is the 2nd test comment about this file...",
"deleted": false,
"resolved": false,
"replies": [
]
},
{
"kind": "drive#comment",
"id": "AAAABg7tSGw",
"createdTime": "2017-11-13T17:43:05.735Z",
"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 a test comment about this file...",
"content": "This is a test comment about this file...",
"deleted": false,
"resolved": true,
"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"
}
]
}
]
}