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".
var
rest: HCkRest;
success: Boolean;
oauth2: HCkOAuth2;
sbJson: HCkStringBuilder;
json: HCkJsonObject;
i: Integer;
count_i: Integer;
kind: PWideChar;
id: PWideChar;
createdTime: PWideChar;
modifiedTime: PWideChar;
authorKind: PWideChar;
authorDisplayName: PWideChar;
authorPhotoLink: PWideChar;
authorMe: Boolean;
htmlContent: PWideChar;
content: PWideChar;
deleted: Boolean;
action: PWideChar;
begin
rest := CkRest_Create();
// Provide a previously obtained OAuth2 access token.
oauth2 := CkOAuth2_Create();
CkOAuth2_putAccessToken(oauth2,'OAUTH2_ACCESS_TOKEN');
CkRest_SetAuthOAuth2(rest,oauth2);
success := CkRest_Connect(rest,'www.googleapis.com',443,True,True);
if (success <> True) then
begin
Memo1.Lines.Add(CkRest__lastErrorText(rest));
Exit;
end;
CkRest_AddQueryParam(rest,'fields','replies');
sbJson := CkStringBuilder_Create();
success := CkRest_FullRequestNoBodySb(rest,'GET','/drive/v3/files/0B5drHSd5ZHwgc3RhcnRlcl9maWxlX2Rhc2hlclYw/comments/AAAABg7tSGw/replies',sbJson);
if (success <> True) then
begin
Memo1.Lines.Add(CkRest__lastErrorText(rest));
Exit;
end;
if (CkRest_getResponseStatusCode(rest) <> 200) then
begin
Memo1.Lines.Add('Received error response code: ' + IntToStr(CkRest_getResponseStatusCode(rest)));
Memo1.Lines.Add('Response body:');
Memo1.Lines.Add(CkStringBuilder__getAsString(sbJson));
Exit;
end;
json := CkJsonObject_Create();
CkJsonObject_LoadSb(json,sbJson);
// The following code parses the JSON response.
// A sample JSON response is shown below the sample code.
i := 0;
count_i := CkJsonObject_SizeOfArray(json,'replies');
while i < count_i do
begin
CkJsonObject_putI(json,i);
kind := CkJsonObject__stringOf(json,'replies[i].kind');
id := CkJsonObject__stringOf(json,'replies[i].id');
createdTime := CkJsonObject__stringOf(json,'replies[i].createdTime');
modifiedTime := CkJsonObject__stringOf(json,'replies[i].modifiedTime');
authorKind := CkJsonObject__stringOf(json,'replies[i].author.kind');
authorDisplayName := CkJsonObject__stringOf(json,'replies[i].author.displayName');
authorPhotoLink := CkJsonObject__stringOf(json,'replies[i].author.photoLink');
authorMe := CkJsonObject_BoolOf(json,'replies[i].author.me');
htmlContent := CkJsonObject__stringOf(json,'replies[i].htmlContent');
content := CkJsonObject__stringOf(json,'replies[i].content');
deleted := CkJsonObject_BoolOf(json,'replies[i].deleted');
action := CkJsonObject__stringOf(json,'replies[i].action');
i := i + 1;
end;
Memo1.Lines.Add('Example Completed.');
CkRest_Dispose(rest);
CkOAuth2_Dispose(oauth2);
CkStringBuilder_Dispose(sbJson);
CkJsonObject_Dispose(json);
{
"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"
}
]
}