Difference between revisions of "AOTG API: Create AR Invoice"

From AutoCount Resource Center
Jump to navigation Jump to search
Line 33: Line 33:
 
}}
 
}}
   
  +
===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.
  +
<syntaxhighlight lang="json-object">
  +
{
  +
"Id": "def14c1a-cdb5-4aa4-834d-0b9c1faa1532",
  +
"Name": "CreateARInvoice",
  +
"StartTimestamp": "2019-03-04T07:43:25.2720622Z",
  +
"EndTimestamp": "2019-03-04T07:43:25.2720622Z"
  +
}
  +
</syntaxhighlight>
   
  +
{{Note|AOTG Cloud Server returns successful response when the request has been performed.<br/>
  +
But this response does not indicate the status of Create AR Invoice.<br/>
  +
Use '''RESULT''' method to acquire the status.
  +
}}
   
  +
<br/>
  +
==Get Status of the Create Debtor==
  +
===Code Snippets===
  +
{{AOTGApiCodeSnippetTab
  +
|Python=
  +
<syntaxhighlight lang="Python">
  +
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)
  +
  +
</syntaxhighlight>
  +
|PHPHttp=
  +
<syntaxhighlight lang="PHP">
  +
<?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;
  +
}
  +
</syntaxhighlight>
  +
|RestSharp=
  +
<syntaxhighlight lang="C#">
  +
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);
  +
</syntaxhighlight>
  +
|PHPcURL=
  +
<syntaxhighlight lang="PHP">
  +
<?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;
  +
}
  +
  +
</syntaxhighlight>
  +
}}
  +
  +
====Response====
  +
200 OK
  +
=====Completed status=====
  +
*'''Completed''' status Indicates that the Create AR Invoice request has been performed and succeeded.
  +
<syntaxhighlight lang="json-object">
  +
{
  +
"RequestId": "def14c1a-cdb5-4aa4-834d-0b9c1faa1532",
  +
"Status": "Completed"
  +
}
  +
</syntaxhighlight>
  +
=====Failed status=====
  +
*'''Failed''' status Indicates that the Create AR Invoice request has been performed but has error.
  +
<syntaxhighlight lang="json-object">
  +
{
  +
"RequestId": "def14c1a-cdb5-4aa4-834d-0b9c1faa1532",
  +
"Status": "Failed"
  +
}
  +
</syntaxhighlight>
   
   

Revision as of 07:52, 4 March 2019

<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

AOTGApiCompleteOrFailFlow.png

  1. Submit CreateARInvoice request to add a new AR Invoice to account book.
  2. Check the successful request status, if the action is Completed or Failed.
  3. 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.



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"
}
Tips icons.png AOTG Cloud Server returns successful response when the request has been performed.

But this response does not indicate the status of Create AR Invoice.
Use RESULT method to acquire the status.


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





See Also AOTG API


Go to menu

IconAC81.png Go to top
ProgrammerGo.jpg Resources For AutoCount Software Developers