Sample code for 30+ languages & platforms
Unicode C

Clear All Multipart Parts

See more REST Examples

Demonstrates Rest.ClearAllParts, which removes all multipart subparts from the request under construction.

Background. Clearing the parts is useful when reusing the same Rest object to build a different multipart request.

Chilkat Unicode C Downloads

Unicode C
#include <C_CkRestW.h>

void ChilkatSample(void)
    {
    BOOL success;
    HCkRestW rest;
    BOOL bTls;
    BOOL bAutoReconnect;

    success = FALSE;

    rest = CkRestW_Create();
    bTls = TRUE;
    bAutoReconnect = TRUE;
    success = CkRestW_Connect(rest,L"example.com",443,bTls,bAutoReconnect);
    if (success == FALSE) {
        wprintf(L"%s\n",CkRestW_lastErrorText(rest));
        CkRestW_Dispose(rest);
        return;
    }

    //  Build a part.
    CkRestW_putPartSelector(rest,L"1");
    success = CkRestW_SetMultipartBodyString(rest,L"value1");
    if (success == FALSE) {
        wprintf(L"%s\n",CkRestW_lastErrorText(rest));
        CkRestW_Dispose(rest);
        return;
    }

    //  Remove all multipart subparts from the request under construction, for example before reusing the
    //  same Rest object for a different multipart request.
    CkRestW_ClearAllParts(rest);

    wprintf(L"All multipart parts cleared.\n");


    CkRestW_Dispose(rest);

    }