<?php
$request = new HttpRequest();
$request->setUrl('http://aotg.cloud:8080/api/public/v1/Lookup/CreditorLookup');
$request->setMethod(HTTP_METH_GET);
$request->setHeaders(array(
'cache-control' => 'no-cache',
'Content-Type' => 'application/json',
'SOTC_AUTH' => 'SAMs1a36d2-a139-e911-b8b3-000aa03t3d'
));
try {
$response = $request->send();
echo $response->getBody();
} catch (HttpException $ex) {
echo $ex;
}
AOTG API: Creditor Lookup: Difference between revisions
Content added Content deleted
(Created page with "{{DRAFT}} ==Creditor Lookup== Get a list of supplier. {{AOTGApiMethodsSpec|GET|/api/public/v1/Lookup/CreditorLookup|Params=$filter, $top}} <br/> ==Code Snippets== *Add header...") |
No edit summary |
||
Line 182: | Line 182: | ||
Use parameter of $filter or $top to filter the result of creditor. |
Use parameter of $filter or $top to filter the result of creditor. |
||
*Below sample uses 3 conditions to '''filter''' the result |
*Below sample uses 3 conditions to '''filter''' the result |
||
*#Creditor code that contains "400-x003", and convert all characters to small letter. |
|||
*#Currency of the creditor is "USD" |
|||
*#Customer who is still active |
|||
<pre> |
<pre> |
||
(substringof('400-x003',tolower(AccNo)) or CurrencyCode eq 'USD') and IsActive eq true |
http://aotg.cloud:8080/api/public/v1/Lookup/CreditorLookup?$filter=(substringof('400-x003',tolower(AccNo)) or CurrencyCode eq 'USD') and IsActive eq true |
||
</pre> |
</pre> |
||
===Code Snippets=== |
|||
{{AOTGApiCodeSnippetTab |
{{AOTGApiCodeSnippetTab |
||
|Python= |
|Python= |
||
<syntaxhighlight lang="Python"> |
<syntaxhighlight lang="Python"> |
||
import requests |
|||
url = "http://aotg.cloud:8080/api/public/v1/Lookup/CreditorLookup" |
|||
querystring = {"$filter":"%28substringof%28%27400-x003%27,tolower%28AccNo%29%29%20or%20CurrencyCode%20eq%20%27USD%27%29%20and%20IsActive%20eq%20true"} |
|||
payload = "" |
|||
headers = { |
|||
'SOTC_AUTH': "SAMs1a36d2-a139-e911-b8b3-000aa03t3d", |
|||
'Content-Type': "application/json", |
|||
'cache-control': "no-cache" |
|||
} |
|||
response = requests.request("GET", url, data=payload, headers=headers, params=querystring) |
|||
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/Lookup/CreditorLookup'); |
|||
$request->setMethod(HTTP_METH_GET); |
|||
$request->setQueryData(array( |
|||
'$filter' => '%28substringof%28%27400-x003%27,tolower%28AccNo%29%29%20or%20CurrencyCode%20eq%20%27USD%27%29%20and%20IsActive%20eq%20true' |
|||
)); |
|||
$request->setHeaders(array( |
|||
'cache-control' => 'no-cache', |
|||
'Content-Type' => 'application/json', |
|||
'SOTC_AUTH' => 'SAMs1a36d2-a139-e911-b8b3-000aa03t3d' |
|||
)); |
|||
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/Lookup/CreditorLookup?$filter=%28substringof%28%27400-x003%27,tolower%28AccNo%29%29%20or%20CurrencyCode%20eq%20%27USD%27%29%20and%20IsActive%20eq%20true"); |
|||
var request = new RestRequest(Method.GET); |
|||
request.AddHeader("cache-control", "no-cache"); |
|||
request.AddHeader("Content-Type", "application/json"); |
|||
request.AddHeader("SOTC_AUTH", "SAMs1a36d2-a139-e911-b8b3-000aa03t3d"); |
|||
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/Lookup/CreditorLookup?$filter=%28substringof%28%27400-x003%27,tolower%28AccNo%29%29%20or%20CurrencyCode%20eq%20%27USD%27%29%20and%20IsActive%20eq%20true", |
|||
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( |
|||
"Content-Type: application/json", |
|||
"SOTC_AUTH: SAMs1a36d2-a139-e911-b8b3-000aa03t3d", |
|||
"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> |
||
}} |
}} |
Revision as of 06:32, 18 March 2019
[DRAFT]
Creditor Lookup
Get a list of supplier.
API Method
Http Method: GET
Method: /api/public/v1/Lookup/CreditorLookup
Content-Type: application/json
Parameters: $filter, $top
Code Snippets
- Add header of "SOTC_AUTH", and assign value of AccessToken.
var client = new RestClient("http://aotg.cloud:8080/api/public/v1/Lookup/CreditorLookup");
var request = new RestRequest(Method.GET);
request.AddHeader("cache-control", "no-cache");
request.AddHeader("Content-Type", "application/json");
request.AddHeader("SOTC_AUTH", "SAMs1a36d2-a139-e911-b8b3-000aa03t3d");
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/Lookup/CreditorLookup",
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(
"Content-Type: application/json",
"SOTC_AUTH: SAMs1a36d2-a139-e911-b8b3-000aa03t3d",
"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/Lookup/CreditorLookup"
payload = ""
headers = {
'SOTC_AUTH': "SAMs1a36d2-a139-e911-b8b3-000aa03t3d",
'Content-Type': "application/json",
'cache-control': "no-cache"
}
response = requests.request("GET", url, data=payload, headers=headers)
print(response.text)
Response
Response Successful HTTP Request
200 OK
Response Successful Body
Sample shows 3 creditors are returned.
[
{
"DataStructureVersion": 5,
"AccNo": "400-X001",
"CompanyName": "XYZ SUPPLIER",
"InvoiceAddress": {
"Contact": "",
"Fax": "",
"Phone": "",
"Address1": "",
"Address2": "",
"Address3": "",
"Address4": ""
},
"PurchaseAgent": "",
"CreditTerm": "C.O.D.",
"IsActive": true,
"CurrencyCode": "MYR",
"CurrencySymbol": "RM",
"IsInclusiveTax": false,
"TaxCode": "",
"DetailDiscount": "",
"SalesExemptionNo": "",
"SalesExemptionExpiryDate": null,
"BranchList": [],
"TaxExemptionList": []
},
{
"DataStructureVersion": 5,
"AccNo": "400-X002",
"CompanyName": "XYZ SUPPLIER (USD)",
"InvoiceAddress": {
"Contact": "",
"Fax": "",
"Phone": "",
"Address1": "",
"Address2": "",
"Address3": "",
"Address4": ""
},
"PurchaseAgent": "",
"CreditTerm": "C.O.D.",
"IsActive": true,
"CurrencyCode": "USD",
"CurrencySymbol": "USD",
"IsInclusiveTax": false,
"TaxCode": "",
"DetailDiscount": "",
"SalesExemptionNo": "",
"SalesExemptionExpiryDate": null,
"BranchList": [],
"TaxExemptionList": []
},
{
"DataStructureVersion": 5,
"AccNo": "400-X003",
"CompanyName": "XYZ SUPPLIER (SGD)",
"InvoiceAddress": {
"Contact": "",
"Fax": "",
"Phone": "",
"Address1": "",
"Address2": "",
"Address3": "",
"Address4": ""
},
"PurchaseAgent": "",
"CreditTerm": "C.O.D.",
"IsActive": true,
"CurrencyCode": "SGD",
"CurrencySymbol": "SGD",
"IsInclusiveTax": false,
"TaxCode": "",
"DetailDiscount": "",
"SalesExemptionNo": "",
"SalesExemptionExpiryDate": null,
"BranchList": [],
"TaxExemptionList": []
}
]
Filter result
Use parameter of $filter or $top to filter the result of creditor.
- Below sample uses 3 conditions to filter the result
- Creditor code that contains "400-x003", and convert all characters to small letter.
- Currency of the creditor is "USD"
- Customer who is still active
http://aotg.cloud:8080/api/public/v1/Lookup/CreditorLookup?$filter=(substringof('400-x003',tolower(AccNo)) or CurrencyCode eq 'USD') and IsActive eq true
Code Snippets
<?php
$request = new HttpRequest();
$request->setUrl('http://aotg.cloud:8080/api/public/v1/Lookup/CreditorLookup');
$request->setMethod(HTTP_METH_GET);
$request->setQueryData(array(
'$filter' => '%28substringof%28%27400-x003%27,tolower%28AccNo%29%29%20or%20CurrencyCode%20eq%20%27USD%27%29%20and%20IsActive%20eq%20true'
));
$request->setHeaders(array(
'cache-control' => 'no-cache',
'Content-Type' => 'application/json',
'SOTC_AUTH' => 'SAMs1a36d2-a139-e911-b8b3-000aa03t3d'
));
try {
$response = $request->send();
echo $response->getBody();
} catch (HttpException $ex) {
echo $ex;
}
var client = new RestClient("http://aotg.cloud:8080/api/public/v1/Lookup/CreditorLookup?$filter=%28substringof%28%27400-x003%27,tolower%28AccNo%29%29%20or%20CurrencyCode%20eq%20%27USD%27%29%20and%20IsActive%20eq%20true");
var request = new RestRequest(Method.GET);
request.AddHeader("cache-control", "no-cache");
request.AddHeader("Content-Type", "application/json");
request.AddHeader("SOTC_AUTH", "SAMs1a36d2-a139-e911-b8b3-000aa03t3d");
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/Lookup/CreditorLookup?$filter=%28substringof%28%27400-x003%27,tolower%28AccNo%29%29%20or%20CurrencyCode%20eq%20%27USD%27%29%20and%20IsActive%20eq%20true",
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(
"Content-Type: application/json",
"SOTC_AUTH: SAMs1a36d2-a139-e911-b8b3-000aa03t3d",
"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/Lookup/CreditorLookup"
querystring = {"$filter":"%28substringof%28%27400-x003%27,tolower%28AccNo%29%29%20or%20CurrencyCode%20eq%20%27USD%27%29%20and%20IsActive%20eq%20true"}
payload = ""
headers = {
'SOTC_AUTH': "SAMs1a36d2-a139-e911-b8b3-000aa03t3d",
'Content-Type': "application/json",
'cache-control': "no-cache"
}
response = requests.request("GET", url, data=payload, headers=headers, params=querystring)
print(response.text)
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
|