Sample code for 30+ languages & platforms
Delphi ActiveX

Isabel Connect Get Account

See more Ibanity Examples

Get the details for a specific account.

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;
cert: TChilkatCert;
privKey: TPrivateKey;
jsonToken: TChilkatJsonObject;
jsonStr: WideString;
jResp: TChilkatJsonObject;
respStatusCode: Integer;
dataAttributesCountry: WideString;
dataAttributesCurrency: WideString;
dataAttributesDescription: WideString;
dataAttributesFinancialInstitutionBic: WideString;
dataAttributesHolderAddress: WideString;
dataAttributesHolderAddressCountry: WideString;
dataAttributesHolderName: WideString;
dataAttributesReference: WideString;
dataAttributesReferenceType: WideString;
dataId: WideString;
dataType: WideString;

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

// Implements the following CURL command:

// curl -X GET https://api.ibanity.com/isabel-connect/accounts/93ecb1fdbfb7848e7b7896c0f2d207aed3d8b4c1 \
// --cert certificate.pem:qwertyuiop1 \
// --key private_key.pem  \
// -H "Authorization: Bearer access_token_1603365407" \
// -H "Accept: application/vnd.api+json"  

// Other Chilkat examples for Ibanity show how to set the SSL client certificate using the .pfx.
// This example will demonstrate using the PEM files.
cert := TChilkatCert.Create(Self);
success := cert.LoadFromFile('qa_data/pem/my_ibanity_certificate.pem');
if (success = 0) then
  begin
    Memo1.Lines.Add(cert.LastErrorText);
    Exit;
  end;
privKey := TPrivateKey.Create(Self);
success := privKey.LoadEncryptedPemFile('qa_data/pem/my_ibanity_private_key.pem','my_pem_password');
if (success = 0) then
  begin
    Memo1.Lines.Add(privKey.LastErrorText);
    Exit;
  end;
success := cert.SetPrivateKey(privKey.ControlInterface);
if (success = 0) then
  begin
    Memo1.Lines.Add(cert.LastErrorText);
    Exit;
  end;
success := http.SetSslClientCert(cert.ControlInterface);
if (success = 0) then
  begin
    Memo1.Lines.Add(http.LastErrorText);
    Exit;
  end;

// Load the previously obtained access token.
jsonToken := TChilkatJsonObject.Create(Self);
success := jsonToken.LoadFile('qa_data/tokens/isabel_access_token.json');
if (success = 0) then
  begin
    Memo1.Lines.Add('No existing access token.');
    Exit;
  end;

// This causes the "Authorization: Bearer ***" header to be added to the HTTP request.
http.AuthToken := jsonToken.StringOf('access_token');

http.Accept := 'application/vnd.api+json';

http.SetUrlVar('id','93ecb1fdbfb7848e7b7896c0f2d207aed3d8b4c1');
jsonStr := http.QuickGetStr('https://api.ibanity.com/isabel-connect/accounts/{$id}');
if (http.LastMethodSuccess = 0) then
  begin
    Memo1.Lines.Add(http.LastErrorText);
    Exit;
  end;

jResp := TChilkatJsonObject.Create(Self);
jResp.Load(jsonStr);
jResp.EmitCompact := 0;

Memo1.Lines.Add('Response Body:');
Memo1.Lines.Add(jResp.Emit());

respStatusCode := http.LastStatus;
Memo1.Lines.Add('Response Status Code = ' + IntToStr(respStatusCode));
if (respStatusCode >= 400) then
  begin
    Memo1.Lines.Add('Response Header:');
    Memo1.Lines.Add(http.LastResponseHeader);
    Memo1.Lines.Add('Failed.');
    Exit;
  end;

// Sample JSON response:
// (Sample code for parsing the JSON response is shown below)

// {
//   "data": {
//     "attributes": {
//       "country": "BE",
//       "currency": "EUR",
//       "description": "current account",
//       "financialInstitutionBic": "KREDBEBB",
//       "holderAddress": "STREET NUMBER, ZIPCODE CITY",
//       "holderAddressCountry": "BE",
//       "holderName": "COMPANY",
//       "reference": "BE96153112434405",
//       "referenceType": "IBAN"
//     },
//     "id": "93ecb1fdbfb7848e7b7896c0f2d207aed3d8b4c1",
//     "type": "account"
//   }
// }

// Sample code for parsing the JSON response...
// Use the following online tool to generate parsing code from sample JSON:
// Generate Parsing Code from JSON

dataAttributesCountry := jResp.StringOf('data.attributes.country');
dataAttributesCurrency := jResp.StringOf('data.attributes.currency');
dataAttributesDescription := jResp.StringOf('data.attributes.description');
dataAttributesFinancialInstitutionBic := jResp.StringOf('data.attributes.financialInstitutionBic');
dataAttributesHolderAddress := jResp.StringOf('data.attributes.holderAddress');
dataAttributesHolderAddressCountry := jResp.StringOf('data.attributes.holderAddressCountry');
dataAttributesHolderName := jResp.StringOf('data.attributes.holderName');
dataAttributesReference := jResp.StringOf('data.attributes.reference');
dataAttributesReferenceType := jResp.StringOf('data.attributes.referenceType');
dataId := jResp.StringOf('data.id');
dataType := jResp.StringOf('data.type');
end;