<?php
$request = new HttpRequest();
$request->setUrl('http://aotg.cloud:8080/api/public/v1/ARInvoice/CreateARInvoice');
$request->setMethod(HTTP_METH_POST);
$request->setHeaders(array(
'cache-control' => 'no-cache',
'Content-Type' => 'application/json',
'SOTC_AUTH' => 'SAMc13a36d2-a139-e911-b8b3-000d3aa04f3d'
));
$request->setBody('{
"DebtorCode": "300-A001",
"Description": "AOTG IMPORT TEST A",
"DocDate": "01-01-2019",
"DocNo": "AOTG007",
"JournalType": "SALES",
"RefNo2": "AOTG Web API",
"InclusiveTax": true,
"Agent": "TOM",
"CreditTerm": "Net 30 days",
"CurrencyCode": "MYR",
"DetailsLine": [
{
"LineState": 0,
"AccNo": "500-0000",
"Description": "AOTG Sales Detail 1",
"Tax": "S-10",
"Amount": 350
},
{
"LineState": 1,
"AccNo": "500-0000",
"Description": "AOTG Sales Detail 2",
"Tax": "S-10",
"Amount": 5
}
]
}');
try {
$response = $request->send();
echo $response->getBody();
} catch (HttpException $ex) {
echo $ex;
}
AOTG API: Create AR Invoice
<DRAFT>
Incompleted!
Create AR Invoice
Add a new AR Invoice to account book
API Method
Http Method: POST
Method: /api/public/v1/ARInvoice/CreateARInvoice
Content-Type: application/json
Parameters: None
API Request Flow
- Submit CreateARInvoice request to add a new AR Invoice to account book.
- Check the successful request status, if the action is Completed or Failed.
- To get the failed reason, use RESULT method to retrieve the message of completed or failed.
Code Snippets
- Add header of "SOTC_AUTH", and assign value of AccessToken.
var client = new RestClient("http://aotg.cloud:8080/api/public/v1/ARInvoice/CreateARInvoice");
var request = new RestRequest(Method.POST);
request.AddHeader("cache-control", "no-cache");
request.AddHeader("Content-Type", "application/json");
request.AddHeader("SOTC_AUTH", "SAMc13a36d2-a139-e911-b8b3-000d3aa04f3d");
request.AddParameter("undefined", "{\r\n \"DebtorCode\": \"300-A001\",\r\n \"Description\": \"AOTG IMPORT TEST A\",\r\n \"DocDate\": \"01-01-2019\",\r\n \"DocNo\": \"AOTG007\",\r\n \"JournalType\": \"SALES\",\r\n \"RefNo2\": \"AOTG Web API\",\r\n \"InclusiveTax\": true,\r\n \"Agent\": \"TOM\",\r\n \"CreditTerm\": \"Net 30 days\",\r\n \"CurrencyCode\": \"MYR\",\r\n \"DetailsLine\": [\r\n {\r\n \"LineState\": 0,\r\n \"AccNo\": \"500-0000\",\r\n \"Description\": \"AOTG Sales Detail 1\",\r\n \"Tax\": \"S-10\",\r\n \"Amount\": 350\r\n },\r\n {\r\n \"LineState\": 1,\r\n \"AccNo\": \"500-0000\",\r\n \"Description\": \"AOTG Sales Detail 2\",\r\n \"Tax\": \"S-10\",\r\n \"Amount\": 5\r\n }\r\n ]\r\n}", ParameterType.RequestBody);
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/ARInvoice/CreateARInvoice",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => "{\r\n \"DebtorCode\": \"300-A001\",\r\n \"Description\": \"AOTG IMPORT TEST A\",\r\n \"DocDate\": \"01-01-2019\",\r\n \"DocNo\": \"AOTG007\",\r\n \"JournalType\": \"SALES\",\r\n \"RefNo2\": \"AOTG Web API\",\r\n \"InclusiveTax\": true,\r\n \"Agent\": \"TOM\",\r\n \"CreditTerm\": \"Net 30 days\",\r\n \"CurrencyCode\": \"MYR\",\r\n \"DetailsLine\": [\r\n {\r\n \"LineState\": 0,\r\n \"AccNo\": \"500-0000\",\r\n \"Description\": \"AOTG Sales Detail 1\",\r\n \"Tax\": \"S-10\",\r\n \"Amount\": 350\r\n },\r\n {\r\n \"LineState\": 1,\r\n \"AccNo\": \"500-0000\",\r\n \"Description\": \"AOTG Sales Detail 2\",\r\n \"Tax\": \"S-10\",\r\n \"Amount\": 5\r\n }\r\n ]\r\n}",
CURLOPT_HTTPHEADER => array(
"Content-Type: application/json",
"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/ARInvoice/CreateARInvoice"
payload = "{\r\n \"DebtorCode\": \"300-A001\",\r\n \"Description\": \"AOTG IMPORT TEST A\",\r\n \"DocDate\": \"01-01-2019\",\r\n \"DocNo\": \"AOTG007\",\r\n \"JournalType\": \"SALES\",\r\n \"RefNo2\": \"AOTG Web API\",\r\n \"InclusiveTax\": true,\r\n \"Agent\": \"TOM\",\r\n \"CreditTerm\": \"Net 30 days\",\r\n \"CurrencyCode\": \"MYR\",\r\n \"DetailsLine\": [\r\n {\r\n \"LineState\": 0,\r\n \"AccNo\": \"500-0000\",\r\n \"Description\": \"AOTG Sales Detail 1\",\r\n \"Tax\": \"S-10\",\r\n \"Amount\": 350\r\n },\r\n {\r\n \"LineState\": 1,\r\n \"AccNo\": \"500-0000\",\r\n \"Description\": \"AOTG Sales Detail 2\",\r\n \"Tax\": \"S-10\",\r\n \"Amount\": 5\r\n }\r\n ]\r\n}"
headers = {
'SOTC_AUTH': "SAMc13a36d2-a139-e911-b8b3-000d3aa04f3d",
'Content-Type': "application/json",
'cache-control': "no-cache"
}
response = requests.request("POST", url, data=payload, headers=headers)
print(response.text)
Response
Response Successful HTTP Request
200 OK
Response Successful Body
- Id and Name can be used to retrieve the status and reason of the failed status.
{
"Id": "def14c1a-cdb5-4aa4-834d-0b9c1faa1532",
"Name": "CreateARInvoice",
"StartTimestamp": "2019-03-04T07:43:25.2720622Z",
"EndTimestamp": "2019-03-04T07:43:25.2720622Z"
}
AOTG Cloud Server returns successful response when the request has been performed. But this response does not indicate the status of Create AR Invoice. |
Get Status of the Create Debtor
Code Snippets
<?php
$request = new HttpRequest();
$request->setUrl('http://aotg.cloud:8080/api/public/v1/Result/def14c1a-cdb5-4aa4-834d-0b9c1faa1532');
$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/def14c1a-cdb5-4aa4-834d-0b9c1faa1532");
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/def14c1a-cdb5-4aa4-834d-0b9c1faa1532",
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/def14c1a-cdb5-4aa4-834d-0b9c1faa1532"
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
200 OK
Completed status
- Completed status Indicates that the Create AR Invoice request has been performed and succeeded.
{
"RequestId": "def14c1a-cdb5-4aa4-834d-0b9c1faa1532",
"Status": "Completed"
}
Failed status
- Failed status Indicates that the Create AR Invoice request has been performed but has error.
{
"RequestId": "def14c1a-cdb5-4aa4-834d-0b9c1faa1532",
"Status": "Failed"
}
Use RESULT method to get the failed reason of Create Debtor request
Code Snippets
Response Successful from HTTP RESULT
200 OK
Result of Failed reason
Debtor record not found
{
"RequestId": "252dacee-59dd-4ac1-85eb-450fc71ef78d",
"RequestName": "CreateARInvoice",
"HostName": "---",
"IPAddress": "---",
"RequestTypeName": null,
"ResultJson": "{\"Message\":\"Debtor record not found (AccNo=300-T001).\",\"StackTrace\":\" at System.Threading.Tasks.Task.ThrowIfExceptional(Boolean includeTaskCanceledExceptions)\\r\\n at System.Threading.Tasks.Task`1.GetResultCore(Boolean waitCompletionNotification)\\r\\n at PSW.SOTC.Accounting.InProcess.AppServiceDispatcher.<DispatchRequest>d__13.MoveNext()\",\"Source\":\"PSW.SOTC.Accounting.Provider.Autocount\"}",
"RequestParamJson": null,
"ResultStream": null,
"ResultTypeName": "PSW.SOTC.Accounting.Provider.Models.ExceptionEntity",
"Status": "Failed",
"Version": "1.2.19051.12002",
"AccountBookInfo": "Plug-In 1.9 Test-1.0.9.77",
"AccountBookDBInfo": "1.0.9.77",
"Timestamp": "2019-03-04T09:03:28.4764315Z",
"ResultedTimestamp": null,
"ProcessingInterval": 0.4542032,
"InQueueInterval": null,
"ResultFileURL": null
}
{
"Message": "Debtor record not found (AccNo=300-T001).",
"StackTrace": " at System.Threading.Tasks.Task.ThrowIfExceptional(Boolean includeTaskCanceledExceptions)rn at System.Threading.Tasks.Task`1.GetResultCore(Boolean waitCompletionNotification)rn at PSW.SOTC.Accounting.InProcess.AppServiceDispatcher.<DispatchRequest>d__13.MoveNext()",
"Source": "PSW.SOTC.Accounting.Provider.Autocount"
}
Debtor record not found
{
"RequestId": "252dacee-59dd-4ac1-85eb-450fc71ef78d",
"RequestName": "CreateARInvoice",
"HostName": "---",
"IPAddress": "---",
"RequestTypeName": null,
"ResultJson": "{\"Message\":\"Debtor record not found (AccNo=300-T001).\",\"StackTrace\":\" at System.Threading.Tasks.Task.ThrowIfExceptional(Boolean includeTaskCanceledExceptions)\\r\\n at System.Threading.Tasks.Task`1.GetResultCore(Boolean waitCompletionNotification)\\r\\n at PSW.SOTC.Accounting.InProcess.AppServiceDispatcher.<DispatchRequest>d__13.MoveNext()\",\"Source\":\"PSW.SOTC.Accounting.Provider.Autocount\"}",
"RequestParamJson": null,
"ResultStream": null,
"ResultTypeName": "PSW.SOTC.Accounting.Provider.Models.ExceptionEntity",
"Status": "Failed",
"Version": "1.2.19051.12002",
"AccountBookInfo": "Plug-In 1.9 Test-1.0.9.77",
"AccountBookDBInfo": "1.0.9.77",
"Timestamp": "2019-03-04T09:03:28.4764315Z",
"ResultedTimestamp": null,
"ProcessingInterval": 0.4542032,
"InQueueInterval": null,
"ResultFileURL": null
}
{
"Message": "Debtor record not found (AccNo=300-T001).",
"StackTrace": " at System.Threading.Tasks.Task.ThrowIfExceptional(Boolean includeTaskCanceledExceptions)rn at System.Threading.Tasks.Task`1.GetResultCore(Boolean waitCompletionNotification)rn at PSW.SOTC.Accounting.InProcess.AppServiceDispatcher.<DispatchRequest>d__13.MoveNext()",
"Source": "PSW.SOTC.Accounting.Provider.Autocount"
}
{
"RequestId": "e6600918-8d9b-4708-9513-c510601efa14", "RequestName": "CreateARInvoice", "HostName": "---", "IPAddress": "---", "RequestTypeName": null, "ResultJson": "{\"Message\":\"Transaction date 02/05/2020 is not in the maintained Fiscal Year Range (01/01/2018 to 31/12/2019), if you want to enter transaction date outside the Fiscal Year Range, please go to Tools | Manage Fiscal Year to add new Fiscal Year.\",\"StackTrace\":\" at System.Threading.Tasks.Task.ThrowIfExceptional(Boolean includeTaskCanceledExceptions)\\r\\n at System.Threading.Tasks.Task`1.GetResultCore(Boolean waitCompletionNotification)\\r\\n at PSW.SOTC.Accounting.InProcess.AppServiceDispatcher.<DispatchRequest>d__13.MoveNext()\",\"Source\":\"PSW.SOTC.Accounting.Provider.Autocount\"}", "RequestParamJson": null, "ResultStream": null, "ResultTypeName": "PSW.SOTC.Accounting.Provider.Models.ExceptionEntity", "Status": "Failed", "Version": "1.2.19051.12002", "AccountBookInfo": "Plug-In 1.9 Test-1.0.9.77", "AccountBookDBInfo": "1.0.9.77", "Timestamp": "2019-03-04T09:35:04.2202143Z", "ResultedTimestamp": null, "ProcessingInterval": 0.76946949999999992, "InQueueInterval": null, "ResultFileURL": null
}
See Also AOTG API
- Introduction to AOTG API
- Begin AutoCount Accounting Integration via AOTG API
- AOTG API Authenticate (Get AccessToken)
Debtor |
AR Invoice |
Item |
Create |
Update |
GL/AR/AP |
General |
Go to top
|
Resources For AutoCount Software Developers
|