AOTG API: Create AR Invoice: Difference between revisions
Content added Content deleted
No edit summary |
No edit summary |
||
Line 21: | Line 21: | ||
|Python= |
|Python= |
||
<syntaxhighlight lang="Python"> |
<syntaxhighlight lang="Python"> |
||
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) |
|||
</syntaxhighlight> |
</syntaxhighlight> |
||
|PHPHttp= |
|PHPHttp= |
||
<syntaxhighlight lang="PHP"> |
<syntaxhighlight lang="PHP"> |
||
<?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; |
|||
} |
|||
</syntaxhighlight> |
</syntaxhighlight> |
||
|RestSharp= |
|RestSharp= |
||
<syntaxhighlight lang="C#"> |
<syntaxhighlight lang="C#"> |
||
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); |
|||
</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/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; |
|||
} |
|||
</syntaxhighlight> |
</syntaxhighlight> |
||
}} |
}} |