AOTG API: Get Debtor: Difference between revisions

From AutoCount Resource Center
Content added Content deleted
(Created page with "==Draft== ==Get Debtor== Get the data of a debtor (customer). *'''debtorId''' is a unique identifier created in AOTG. *See AOTG API: Get List of Debtor#Response_From_Resul...")
 
No edit summary
Line 7: Line 7:
*See [[AOTG API: Get List of Debtor#Response_From_Result|Get List of Debtor]] on how to obtain '''Id''' (that is created in AOTG).
*See [[AOTG API: Get List of Debtor#Response_From_Result|Get List of Debtor]] on how to obtain '''Id''' (that is created in AOTG).
{{AOTGApiMethodsSpec|GET|/api/public/v1/Debtor/{debtorId} }}
{{AOTGApiMethodsSpec|GET|/api/public/v1/Debtor/{debtorId} }}

==API Request Flow==
==API Request Flow==
[[File:AOTGApiRequestFlow.png|link=]]
#Submit GetDebtor request for a debtor with an Id of the debtor
#Check the successful request status, if the data is completed (ready).
#Retrieve the data with '''Result method'''.

==Code Snippets==
==Code Snippets==
*Add header of '''"SOTC_AUTH"''', and assign value of '''AccessToken'''.
*Add header of '''"SOTC_AUTH"''', and assign value of '''AccessToken'''.
{{AOTGApiCodeSnippetTab
{{AOTGApiCodeSnippetTab
|Python=
<syntaxhighlight lang="Python">
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)
</syntaxhighlight>
|PHPHttp=
|PHPHttp=
<syntaxhighlight lang="PHP">
<syntaxhighlight lang="PHP">
<?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;
}
</syntaxhighlight>
</syntaxhighlight>
|RestSharp=
|RestSharp=
<syntaxhighlight lang="C#">
<syntaxhighlight lang="C#">
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);
</syntaxhighlight>
</syntaxhighlight>
|PHPcURL=
|PHPcURL=
<syntaxhighlight lang="PHP">
<syntaxhighlight lang="PHP">
<?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;
}
</syntaxhighlight>
</syntaxhighlight>
}}
}}
Line 28: Line 101:
200 OK
200 OK
====Response Successful Body====
====Response Successful Body====
*'''Id''' and '''Name''' can be used to retrieve the status and reason of the failed status.
*'''Id''' can be used to check the status of the data readiness.
*'''Id''' and '''Name''' can be used to retrieve the debtor data.
<syntaxhighlight lang="json-object">
<syntaxhighlight lang="json-object" highlight="2,3">

{
"Id": "7d472828-b1df-44fe-8a7b-1e737ca09ba5",
"Name": "GetDebtor",
"StartTimestamp": "2019-03-01T06:24:28.0847569Z",
"EndTimestamp": "2019-03-01T06:24:28.0847569Z"
}
</syntaxhighlight>
</syntaxhighlight>



Revision as of 06:45, 1 March 2019

Draft

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: 

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"
}



See Also AOTG API


Go to menu

Go to top
Resources For AutoCount Software Developers