Sample code for 30+ languages & platforms
Delphi ActiveX

qa.factura1.com.co Obtain Auth Token

See more HTTP Misc Examples

Demonstrates how to send a JSON POST to get an authenticataion token for qa.factura1.com.co

Chilkat Delphi ActiveX Downloads

Delphi ActiveX
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;
json: TChilkatJsonObject;
resp: TChilkatHttpResponse;
jsonResp: TChilkatJsonObject;

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);

// Build the following JSON
// {
//   "password": "MY_PASSWORD",
//   "username": "MY_USERNAME"
// }

json := TChilkatJsonObject.Create(Self);
json.EmitCompact := 0;
json.UpdateString('password','MY_PASSWORD');
json.UpdateString('username','MY_USERNAME');

resp := TChilkatHttpResponse.Create(Self);
success := http.HttpJson('POST','https://qa.factura1.com.co/v2/auth',json.ControlInterface,'application/json',resp.ControlInterface);
if (success = 0) then
  begin
    Memo1.Lines.Add(http.LastErrorText);
    Exit;
  end;

jsonResp := TChilkatJsonObject.Create(Self);
jsonResp.EmitCompact := 0;
jsonResp.Load(resp.BodyStr);

Memo1.Lines.Add(jsonResp.Emit());

Memo1.Lines.Add('Access token: ' + jsonResp.StringOf('token'));
end;