Delphi ActiveX Requires Chilkat v11.0.0+
Delphi ActiveX
HTTP POST with Binary Data in Request Body
See more HTTP Examples
Do an HTTPS POST with a binary request body.Chilkat Delphi ActiveX Downloads
var
success: Integer;
http: TChilkatHttp;
fac: TCkFileAccess;
reqBody: Array of Byte;
resp: TChilkatHttpResponse;
responseStatusCode: Integer;
begin
success := 0;
// This example assumes the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.
http := TChilkatHttp.Create(Self);
fac := TCkFileAccess.Create(Self);
reqBody := fac.ReadEntireFile('qa_data/pdf/helloWorld.pdf');
resp := TChilkatHttpResponse.Create(Self);
success := http.HttpBinary('POST','https://example.com/something',reqBody,'application/pdf',resp.ControlInterface);
if (success = 0) then
begin
Memo1.Lines.Add(http.LastErrorText);
Exit;
end;
responseStatusCode := resp.StatusCode;
Memo1.Lines.Add('Status code: ' + IntToStr(responseStatusCode));
// For example, if the response is XML, JSON, HTML, etc.
Memo1.Lines.Add('response body:');
Memo1.Lines.Add(resp.BodyStr);