Unicode C Google Drive: Delete a Comment

Back to Index

Deletes a particular comment on a file. The file is specified by file ID. This example deletes the comment (id="AAAABg7vWfw") from the file having id = "0B5drHSd5ZHwgc3RhcnRlcl9maWxlX2Rhc2hlclYw".

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


#include <C_CkRestW.h>
#include <C_CkOAuth2W.h>
#include <C_CkStringBuilderW.h>

void ChilkatSample(void)
    {
    HCkRestW rest;
    BOOL success;
    HCkOAuth2W oauth2;
    HCkStringBuilderW sbResponse;

    rest = CkRestW_Create();

    //   Provide a previously obtained OAuth2 access token.
    oauth2 = CkOAuth2W_Create();
    CkOAuth2W_putAccessToken(oauth2,L"OAUTH2_ACCESS_TOKEN");
    CkRestW_SetAuthOAuth2(rest,oauth2);

    success = CkRestW_Connect(rest,L"www.googleapis.com",443,TRUE,TRUE);
    if (success != TRUE) {
        wprintf(L"%s\n",CkRestW_lastErrorText(rest));
        CkRestW_Dispose(rest);
        CkOAuth2W_Dispose(oauth2);
        return;
    }

    sbResponse = CkStringBuilderW_Create();
    success = CkRestW_FullRequestNoBodySb(rest,L"DELETE",L"/drive/v3/files/0B5drHSd5ZHwgc3RhcnRlcl9maWxlX2Rhc2hlclYw/comments/AAAABg7vWfw",sbResponse);
    if (success != TRUE) {
        wprintf(L"%s\n",CkRestW_lastErrorText(rest));
        CkRestW_Dispose(rest);
        CkOAuth2W_Dispose(oauth2);
        CkStringBuilderW_Dispose(sbResponse);
        return;
    }

    if (CkRestW_getResponseStatusCode(rest) != 204) {
        wprintf(L"Received error response code: %d\n",CkRestW_getResponseStatusCode(rest));
        wprintf(L"Response body:\n");
        wprintf(L"%s\n",CkStringBuilderW_getAsString(sbResponse));
        CkRestW_Dispose(rest);
        CkOAuth2W_Dispose(oauth2);
        CkStringBuilderW_Dispose(sbResponse);
        return;
    }

    wprintf(L"Example Completed.\n");


    CkRestW_Dispose(rest);
    CkOAuth2W_Dispose(oauth2);
    CkStringBuilderW_Dispose(sbResponse);

    }