Delphi DLL Requires Chilkat v11.0.0+
Delphi DLL
HTTP POST with Binary Data in Request Body
See more HTTP Examples
Do an HTTPS POST with a binary request body.Chilkat Delphi DLL Downloads
var
success: Boolean;
http: HCkHttp;
fac: HCkFileAccess;
reqBody: HCkByteData;
resp: HCkHttpResponse;
responseStatusCode: Integer;
begin
success := False;
// This example assumes the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.
http := CkHttp_Create();
fac := CkFileAccess_Create();
reqBody := CkByteData_Create();
success := CkFileAccess_ReadEntireFile(fac,'qa_data/pdf/helloWorld.pdf',reqBody);
resp := CkHttpResponse_Create();
success := CkHttp_HttpBinary(http,'POST','https://example.com/something',reqBody,'application/pdf',resp);
if (success = False) then
begin
Memo1.Lines.Add(CkHttp__lastErrorText(http));
Exit;
end;
responseStatusCode := CkHttpResponse_getStatusCode(resp);
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(CkHttpResponse__bodyStr(resp));
CkHttp_Dispose(http);
CkFileAccess_Dispose(fac);
CkByteData_Dispose(reqBody);
CkHttpResponse_Dispose(resp);