Sample code for 30+ languages & platforms
Delphi DLL

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 Delphi DLL Downloads

Delphi DLL
var
success: Boolean;
rest: HCkRest;
bTls: Boolean;
bAutoReconnect: Boolean;

begin
success := False;

rest := CkRest_Create();
bTls := True;
bAutoReconnect := True;
success := CkRest_Connect(rest,'example.com',443,bTls,bAutoReconnect);
if (success = False) then
  begin
    Memo1.Lines.Add(CkRest__lastErrorText(rest));
    Exit;
  end;

//  Build a part.
CkRest_putPartSelector(rest,'1');
success := CkRest_SetMultipartBodyString(rest,'value1');
if (success = False) then
  begin
    Memo1.Lines.Add(CkRest__lastErrorText(rest));
    Exit;
  end;

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

Memo1.Lines.Add('All multipart parts cleared.');

CkRest_Dispose(rest);