Unicode C Box: Delete Folder

Back to Index

Move a folder to the trash. The recursive parameter must be included in order to delete folders that aren't empty. This example deletes the folder w/ id = 47885473705. An empty 204 response will be returned upon successful deletion. An error is thrown if the folder is not empty and the ‘recursive’ parameter is not included.

Documentation: https://developer.box.com/reference#delete-a-folder

CURL Command

curl https://api.box.com/2.0/folders/47885473705?recursive=true \
-H "Authorization: Bearer BOX_ACCESS_TOKEN" \
-X DELETE

Unicode C Example

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

void ChilkatSample(void)
    {
    HCkRestW rest;
    BOOL success;
    BOOL bTls;
    int port;
    BOOL bAutoReconnect;
    HCkStringBuilderW sbResponseBody;

    rest = CkRestW_Create();

    //  URL: https://api.box.com/2.0/folders/47885473705?recursive=true
    bTls = TRUE;
    port = 443;
    bAutoReconnect = TRUE;
    success = CkRestW_Connect(rest,L"api.box.com",port,bTls,bAutoReconnect);
    if (success != TRUE) {
        wprintf(L"ConnectFailReason: %d\n",CkRestW_getConnectFailReason(rest));
        wprintf(L"%s\n",CkRestW_lastErrorText(rest));
        CkRestW_Dispose(rest);
        return;
    }

    CkRestW_AddHeader(rest,L"Authorization",L"Bearer BOX_ACCESS_TOKEN");

    sbResponseBody = CkStringBuilderW_Create();
    success = CkRestW_FullRequestNoBodySb(rest,L"DELETE",L"/2.0/folders/47885473705?recursive=true",sbResponseBody);
    if (success != TRUE) {
        wprintf(L"%s\n",CkRestW_lastErrorText(rest));
        CkRestW_Dispose(rest);
        CkStringBuilderW_Dispose(sbResponseBody);
        return;
    }



    CkRestW_Dispose(rest);
    CkStringBuilderW_Dispose(sbResponseBody);

    }