Sample code for 30+ languages & platforms
PureBasic

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 PureBasic Downloads

PureBasic
IncludeFile "CkRest.pb"

Procedure ChilkatExample()

    success.i = 0

    rest.i = CkRest::ckCreate()
    If rest.i = 0
        Debug "Failed to create object."
        ProcedureReturn
    EndIf

    bTls.i = 1
    bAutoReconnect.i = 1
    success = CkRest::ckConnect(rest,"example.com",443,bTls,bAutoReconnect)
    If success = 0
        Debug CkRest::ckLastErrorText(rest)
        CkRest::ckDispose(rest)
        ProcedureReturn
    EndIf

    ;  Build a part.
    CkRest::setCkPartSelector(rest, "1")
    success = CkRest::ckSetMultipartBodyString(rest,"value1")
    If success = 0
        Debug CkRest::ckLastErrorText(rest)
        CkRest::ckDispose(rest)
        ProcedureReturn
    EndIf

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

    Debug "All multipart parts cleared."


    CkRest::ckDispose(rest)


    ProcedureReturn
EndProcedure