AOTG API: Get Debtor

From AutoCount Resource Center

Get Debtor

Get the data of a debtor (customer).

  • debtorId is a unique identifier created in AOTG.
  • See Get List of Debtor on how to obtain Id (that is created in AOTG).

API Method

Http Method: GET
Method: /api/public/v1/Debtor/{debtorId}
Content-Type: application/json
Parameters: None

API Request Flow

  1. Submit GetDebtor request for a debtor with an Id of the debtor
  2. Check the successful request status, if the data is completed (ready).
  3. Retrieve the data with Result method.

Code Snippets

  • Add header of "SOTC_AUTH", and assign value of AccessToken.

<?php

$request = new HttpRequest();
$request->setUrl('http://aotg.cloud:8080/api/public/v1/Debtor/{[%21MzAwLUEwMDI%21]}');
$request->setMethod(HTTP_METH_GET);

$request->setHeaders(array(
  'cache-control' => 'no-cache',
  'SOTC_AUTH' => 'SAMc13a36d2-a139-e911-b8b3-000d3aa04f3d'
));

try {
  $response = $request->send();

  echo $response->getBody();
} catch (HttpException $ex) {
  echo $ex;
}

var client = new RestClient("http://aotg.cloud:8080/api/public/v1/Debtor/{[%21MzAwLUEwMDI%21]}");
var request = new RestRequest(Method.GET);
request.AddHeader("cache-control", "no-cache");
request.AddHeader("SOTC_AUTH", "SAMc13a36d2-a139-e911-b8b3-000d3aa04f3d");
IRestResponse response = client.Execute(request);

<?php

$curl = curl_init();

curl_setopt_array($curl, array(
  CURLOPT_PORT => "8080",
  CURLOPT_URL => "http://aotg.cloud:8080/api/public/v1/Debtor/{[%21MzAwLUEwMDI%21]}",
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => "",
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 30,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => "GET",
  CURLOPT_POSTFIELDS => "",
  CURLOPT_HTTPHEADER => array(
    "SOTC_AUTH: SAMc13a36d2-a139-e911-b8b3-000d3aa04f3d",
    "cache-control: no-cache"
  ),
));

$response = curl_exec($curl);
$err = curl_error($curl);

curl_close($curl);

if ($err) {
  echo "cURL Error #:" . $err;
} else {
  echo $response;
}

import requests

url = "http://aotg.cloud:8080/api/public/v1/Debtor/{[%21MzAwLUEwMDI%21]}"

payload = ""
headers = {
    'SOTC_AUTH': "SAMc13a36d2-a139-e911-b8b3-000d3aa04f3d",
    'cache-control': "no-cache",
    }

response = requests.request("GET", url, data=payload, headers=headers)

print(response.text)


Response

  • Successful Response indicates GetDebtor has been performed.

Response Successful HTTP Request

200 OK

Response Successful Body

  • Id can be used to check the status of the data readiness.
  • Id and Name can be used to retrieve the debtor data.
{
    "Id": "7d472828-b1df-44fe-8a7b-1e737ca09ba5",
    "Name": "GetDebtor",
    "StartTimestamp": "2019-03-01T06:24:28.0847569Z",
    "EndTimestamp": "2019-03-01T06:24:28.0847569Z"
}

Check Status

Code Snippets

<?php

$request = new HttpRequest();
$request->setUrl('http://aotg.cloud:8080/api/public/v1/Result/7d472828-b1df-44fe-8a7b-1e737ca09ba5');
$request->setMethod(HTTP_METH_GET);

$request->setHeaders(array(
  'cache-control' => 'no-cache',
  'SOTC_AUTH' => 'SAMc13a36d2-a139-e911-b8b3-000d3aa04f3d'
));

try {
  $response = $request->send();

  echo $response->getBody();
} catch (HttpException $ex) {
  echo $ex;
}

var client = new RestClient("http://aotg.cloud:8080/api/public/v1/Result/7d472828-b1df-44fe-8a7b-1e737ca09ba5");
var request = new RestRequest(Method.GET);
request.AddHeader("cache-control", "no-cache");
request.AddHeader("SOTC_AUTH", "SAMc13a36d2-a139-e911-b8b3-000d3aa04f3d");
IRestResponse response = client.Execute(request);

<?php

$curl = curl_init();

curl_setopt_array($curl, array(
  CURLOPT_PORT => "8080",
  CURLOPT_URL => "http://aotg.cloud:8080/api/public/v1/Result/7d472828-b1df-44fe-8a7b-1e737ca09ba5",
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => "",
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 30,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => "GET",
  CURLOPT_POSTFIELDS => "",
  CURLOPT_HTTPHEADER => array(
    "SOTC_AUTH: SAMc13a36d2-a139-e911-b8b3-000d3aa04f3d",
    "cache-control: no-cache"
  ),
));

$response = curl_exec($curl);
$err = curl_error($curl);

curl_close($curl);

if ($err) {
  echo "cURL Error #:" . $err;
} else {
  echo $response;
}

import requests

url = "http://aotg.cloud:8080/api/public/v1/Result/7d472828-b1df-44fe-8a7b-1e737ca09ba5"

payload = ""
headers = {
    'SOTC_AUTH': "SAMc13a36d2-a139-e911-b8b3-000d3aa04f3d",
    'cache-control': "no-cache",
    }

response = requests.request("GET", url, data=payload, headers=headers)

print(response.text)


Response Status

4 possible responses from process status.

InQueue status
  • InQueue status Indicates that the requests to AOTG Server is waiting to be processed.
  • Usually this happen when many requests are called to AOTG Web API in within a second.
    Make sure the request in the loop has pause time,
    or use 'batch' method to process multiple records in single request if applicable.
"RequestId": "7d472828-b1df-44fe-8a7b-1e737ca09ba5",
"Status": "InQueue"
Processing status
  • Processing status indicates that the request is not complete.
"RequestId": "7d472828-b1df-44fe-8a7b-1e737ca09ba5",
"Status": "Processing"
Completed status
  • Completed status Indicates that the request has been performed and succeeded.
"RequestId": "7d472828-b1df-44fe-8a7b-1e737ca09ba5",
"Status": "Completed"
Failed status
  • Failed status indicates that the request has been performed but has error.
"RequestId": "7d472828-b1df-44fe-8a7b-1e737ca09ba5",
"Status": "Failed"


Get Data (Result)

Code Snippets

<?php

$request = new HttpRequest();
$request->setUrl('http://aotg.cloud:8080/api/public/v1/Result/GetDebtor/7d472828-b1df-44fe-8a7b-1e737ca09ba5/result');
$request->setMethod(HTTP_METH_GET);

$request->setHeaders(array(
  'cache-control' => 'no-cache',
  'SOTC_AUTH' => 'SAMc13a36d2-a139-e911-b8b3-000d3aa04f3d'
));

try {
  $response = $request->send();

  echo $response->getBody();
} catch (HttpException $ex) {
  echo $ex;
}

var client = new RestClient("http://aotg.cloud:8080/api/public/v1/Result/GetDebtor/7d472828-b1df-44fe-8a7b-1e737ca09ba5/result");
var request = new RestRequest(Method.GET);
request.AddHeader("cache-control", "no-cache");
request.AddHeader("SOTC_AUTH", "SAMc13a36d2-a139-e911-b8b3-000d3aa04f3d");
IRestResponse response = client.Execute(request);

<?php

$curl = curl_init();

curl_setopt_array($curl, array(
  CURLOPT_PORT => "8080",
  CURLOPT_URL => "http://aotg.cloud:8080/api/public/v1/Result/GetDebtor/7d472828-b1df-44fe-8a7b-1e737ca09ba5/result",
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => "",
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 30,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => "GET",
  CURLOPT_POSTFIELDS => "",
  CURLOPT_HTTPHEADER => array(
    "SOTC_AUTH: SAMc13a36d2-a139-e911-b8b3-000d3aa04f3d",
    "cache-control: no-cache"
  ),
));

$response = curl_exec($curl);
$err = curl_error($curl);

curl_close($curl);

if ($err) {
  echo "cURL Error #:" . $err;
} else {
  echo $response;
}

import requests

url = "http://aotg.cloud:8080/api/public/v1/Result/GetDebtor/7d472828-b1df-44fe-8a7b-1e737ca09ba5/result"

payload = ""
headers = {
    'SOTC_AUTH': "SAMc13a36d2-a139-e911-b8b3-000d3aa04f3d",
    'cache-control': "no-cache",
    }

response = requests.request("GET", url, data=payload, headers=headers)

print(response.text)


Response From Result

Response Successful HTTP Request
200 OK
Response Successful Body

{
    "RequestId": "7d472828-b1df-44fe-8a7b-1e737ca09ba5",
    "RequestName": "GetDebtor",
    "HostName": "---",
    "IPAddress": "---",
    "RequestTypeName": "Debtor",
    "ResultJson": "{\"Id\":\"{[!MzAwLUEwMDI!]}\",\"AccNo\":\"300-A002\",\"CompanyName\":\"AutoCount On The Go\",\"RegisterNo\":\"\",\"Description\":\"AOTG\",\"InvoiceAddress\":{\"Contact\":\"Mr.Tan\",\"Fax\":\"\",\"Phone\":\"02111373\",\"Address1\":\"1/2, PINE STREET,\",\"Address2\":\"CENTURY ROAD,\",\"Address3\":\"SELANGOR\",\"Address4\":\"50000 MALAYSIA\"},\"DeliverAddress\":{\"Contact\":\"Mr.Tan\",\"Fax\":\"\",\"Phone\":\"02111373\",\"Address1\":\"1/2, PINE STREET,\",\"Address2\":\"Delivery CENTURY ROAD,\",\"Address3\":\"SELANGOR\",\"Address4\":\"50000 MALAYSIA\"},\"SalesAgent\":\"\",\"CreditTerm\":\"C.O.D.\",\"CreditLimit\":30000.00,\"NatureOfBusiness\":\"\",\"WebURL\":\"\",\"EmailAddress\":\"\",\"Outstanding\":0.0,\"IsActive\":true,\"CurrencyCode\":\"MYR\",\"CurrencySymbol\":\"RM\",\"BlockExceedCreditLimit\":false,\"TaxCode\":\"\",\"TaxRegistrationNo\":\"\",\"IsTaxRegistered\":false,\"GSTStatusVerifiedDate\":null,\"IsInclusiveTax\":false,\"Area\":\"\",\"PriceCategory\":\"\",\"DetailDiscount\":null,\"SalesExemptionNo\":\"\",\"SalesExemptionExpiryDate\":null,\"BranchList\":[],\"TaxExemptionList\":[]}",
    "RequestParamJson": null,
    "ResultStream": null,
    "ResultTypeName": "PSW.SOTC.Accounting.Provider.Models.DebtorEntity",
    "Status": "Completed",
    "Version": "1.2.19051.12002",
    "AccountBookInfo": "Plug-In 1.9 Test;1.0.9.77",
    "AccountBookDBInfo": "1.0.9.77",
    "Timestamp": "2019-03-01T07:54:37.2578124Z",
    "ResultedTimestamp": "2019-03-01T07:54:37.3147722Z",
    "ProcessingInterval": 0.52409549999999994,
    "InQueueInterval": 1.6724054,
    "ResultFileURL": null
}

{
  "Id": "{[!MzAwLUEwMDI!]}",
  "AccNo": "300-A002",
  "CompanyName": "AutoCount On The Go",
  "RegisterNo": "",
  "Description": "AOTG",
  "InvoiceAddress": {
    "Contact": "Mr.Tan",
    "Fax": "",
    "Phone": "02111373",
    "Address1": "1/2, PINE STREET,",
    "Address2": "CENTURY ROAD,",
    "Address3": "SELANGOR",
    "Address4": "50000 MALAYSIA"
  },
  "DeliverAddress": {
    "Contact": "Mr.Tan",
    "Fax": "",
    "Phone": "02111373",
    "Address1": "1/2, PINE STREET,",
    "Address2": "Delivery CENTURY ROAD,",
    "Address3": "SELANGOR",
    "Address4": "50000 MALAYSIA"
  },
  "SalesAgent": "",
  "CreditTerm": "C.O.D.",
  "CreditLimit": 30000,
  "NatureOfBusiness": "",
  "WebURL": "",
  "EmailAddress": "",
  "Outstanding": 0,
  "IsActive": true,
  "CurrencyCode": "MYR",
  "CurrencySymbol": "RM",
  "BlockExceedCreditLimit": false,
  "TaxCode": "",
  "TaxRegistrationNo": "",
  "IsTaxRegistered": false,
  "GSTStatusVerifiedDate": null,
  "IsInclusiveTax": false,
  "Area": "",
  "PriceCategory": "",
  "DetailDiscount": null,
  "SalesExemptionNo": "",
  "SalesExemptionExpiryDate": null,
  "BranchList": [],
  "TaxExemptionList": []
}


See Also AOTG API


Go to menu

Go to top
Resources For AutoCount Software Developers