Delphi ActiveX
Delphi ActiveX
Send HTTPS POST with XML Body
See more HTTP Examples
Demonstrates how to send an HTTP (or HTTPS) POST where the body of the request is XML.Chilkat Delphi ActiveX Downloads
uses
Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.StdCtrls, Chilkat_TLB;
...
procedure TForm1.Button1Click(Sender: TObject);
var
success: Integer;
http: TChilkatHttp;
strXml: WideString;
resp: TChilkatHttpResponse;
begin
success := 0;
// This example requires the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.
http := TChilkatHttp.Create(Self);
strXml := '<TransactionSetup xmlns="https://xyz.com"><Credentials><AccountID>XXX</AccountID></Credentials></TransactionSetup>';
// Maybe you need other headers?
http.SetRequestHeader('Accept','application/xml');
resp := TChilkatHttpResponse.Create(Self);
success := http.HttpStr('POST','https://www.somewebsite.com/',strXml,'utf-8','application/xml',resp.ControlInterface);
if (success = 0) then
begin
Memo1.Lines.Add(http.LastErrorText);
Exit;
end;
// Examine the response status code:
Memo1.Lines.Add('response status code = ' + IntToStr(resp.StatusCode));
// Examine the response body:
Memo1.Lines.Add('response body: ' + resp.BodyStr);
end;