PowerBuilder Google Drive: Delete a Reply from a Comment

Back to Index

Deletes a reply from a comment. This example deletes reply (id="AAAABg76H9o") from a comment (id="AAAABg7tSGw") on the file (id= "0B5drHSd5ZHwgc3RhcnRlcl9maWxlX2Rhc2hlclYw")

Documentation: https://developers.google.com/drive/v3/reference/replies/delete


integer li_rc
oleobject loo_Rest
integer li_Success
oleobject loo_Oauth2
oleobject loo_SbResponse

loo_Rest = create oleobject
li_rc = loo_Rest.ConnectToNewObject("Chilkat_9_5_0.Rest")
if li_rc < 0 then
    destroy loo_Rest
    MessageBox("Error","Connecting to COM object failed")
    return
end if

//   Provide a previously obtained OAuth2 access token.
loo_Oauth2 = create oleobject
li_rc = loo_Oauth2.ConnectToNewObject("Chilkat_9_5_0.OAuth2")

loo_Oauth2.AccessToken = "OAUTH2_ACCESS_TOKEN"
loo_Rest.SetAuthOAuth2(loo_Oauth2)

li_Success = loo_Rest.Connect("www.googleapis.com",443,1,1)
if li_Success <> 1 then
    Write-Debug loo_Rest.LastErrorText
    destroy loo_Rest
    destroy loo_Oauth2
    return
end if

loo_SbResponse = create oleobject
li_rc = loo_SbResponse.ConnectToNewObject("Chilkat_9_5_0.StringBuilder")

li_Success = loo_Rest.FullRequestNoBodySb("DELETE","/drive/v3/files/0B5drHSd5ZHwgc3RhcnRlcl9maWxlX2Rhc2hlclYw/comments/AAAABg7tSGw/replies/AAAABg76H9o",loo_SbResponse)
if li_Success <> 1 then
    Write-Debug loo_Rest.LastErrorText
    destroy loo_Rest
    destroy loo_Oauth2
    destroy loo_SbResponse
    return
end if

if loo_Rest.ResponseStatusCode <> 204 then
    Write-Debug "Received error response code: " + string(loo_Rest.ResponseStatusCode)
    Write-Debug "Response body:"
    Write-Debug loo_SbResponse.GetAsString()
    destroy loo_Rest
    destroy loo_Oauth2
    destroy loo_SbResponse
    return
end if

Write-Debug "Example Completed."


destroy loo_Rest
destroy loo_Oauth2
destroy loo_SbResponse