AOTG API: Update Debtor

Revision as of 03:07, 28 February 2019 by DanielY (talk | contribs)

Update Debtor

Update a specific Debtor.

API Method

Http Method: PUT
Method: /api/public/v1/Debtor
Content-Type: application/json
Parameters: 


Code Snippets

  • Add header of "SOTC_AUTH", and assign value of AccessToken.
  • The value "{[!MzAwLUEwMDI!]}" of Id in the body is a unique identifier of a specific debtor that is generated by AOTG.
  • :See Get List of Debtor on how to obtain Id (that is created in AOTG).
  • Description is actually "Desc2" in AutoCount Accounting. It is the 2nd line of the Company Name in AutoCount Accounting.
    Example:
Company Name Alibaba Group Holding Limited
Description (Desc2) 阿里巴巴集团控股有限公司


<?php

$request = new HttpRequest();
$request->setUrl('http://aotg.cloud:8080/api/public/v1/Debtor');
$request->setMethod(HTTP_METH_PUT);

$request->setHeaders(array(
  'cache-control' => 'no-cache',
  'SOTC_AUTH' => 'SAMc13a36d2-a139-e911-b8b3-000d3aa04f3d',
  'Content-Type' => 'application/json'
));

$request->setBody('{
	"Id": "{[!MzAwLUEwMDI!]}",
	"CompanyName": "AutoCount On The Go",
	"RegisterNo": "",
	"Description": "AOTG Team",
	"InvoiceAddress": {
	  "Contact": "Mr.Lee",
	  "Fax": "",
	  "Phone": "02111373",
	  "Address1": "1/2, PINE STREET,",
	  "Address2": "CENTURY ROAD,",
	  "Address3": "SELANGOR",
	  "Address4": "50000 MALAYSIA"
	},
	"DeliverAddress": {
	  "Contact": "Mr.Tan",
	  "Fax": "",
	  "Phone": "02111373",
	  "Address1": "1/2, PINE STREET,",
	  "Address2": "Delivery CENTURY ROAD,",
	  "Address3": "SELANGOR",
	  "Address4": "50000 MALAYSIA"
	},
	"CreditTerm": "C.O.D.",
	"CreditLimit": 30000,
	"WebURL": "",
	"EmailAddress": "",
	"IsActive": true,
	"CurrencyCode": "MYR",
	"IsTaxRegistered": null,
	"IsInclusiveTax": false
	}
}');

try {
  $response = $request->send();

  echo $response->getBody();
} catch (HttpException $ex) {
  echo $ex;
}

var client = new RestClient("http://aotg.cloud:8080/api/public/v1/Debtor");
var request = new RestRequest(Method.PUT);
request.AddHeader("cache-control", "no-cache");
request.AddHeader("SOTC_AUTH", "SAMc13a36d2-a139-e911-b8b3-000d3aa04f3d");
request.AddHeader("Content-Type", "application/json");
request.AddParameter("undefined", "{\r\n\t\"Id\": \"{[!MzAwLUEwMDI!]}\",\r\n\t\"CompanyName\": \"AutoCount On The Go\",\r\n\t\"RegisterNo\": \"\",\r\n\t\"Description\": \"AOTG Team\",\r\n\t\"InvoiceAddress\": {\r\n\t  \"Contact\": \"Mr.Lee\",\r\n\t  \"Fax\": \"\",\r\n\t  \"Phone\": \"02111373\",\r\n\t  \"Address1\": \"1/2, PINE STREET,\",\r\n\t  \"Address2\": \"CENTURY ROAD,\",\r\n\t  \"Address3\": \"SELANGOR\",\r\n\t  \"Address4\": \"50000 MALAYSIA\"\r\n\t},\r\n\t\"DeliverAddress\": {\r\n\t  \"Contact\": \"Mr.Tan\",\r\n\t  \"Fax\": \"\",\r\n\t  \"Phone\": \"02111373\",\r\n\t  \"Address1\": \"1/2, PINE STREET,\",\r\n\t  \"Address2\": \"Delivery CENTURY ROAD,\",\r\n\t  \"Address3\": \"SELANGOR\",\r\n\t  \"Address4\": \"50000 MALAYSIA\"\r\n\t},\r\n\t\"CreditTerm\": \"C.O.D.\",\r\n\t\"CreditLimit\": 30000,\r\n\t\"WebURL\": \"\",\r\n\t\"EmailAddress\": \"\",\r\n\t\"IsActive\": true,\r\n\t\"CurrencyCode\": \"MYR\",\r\n\t\"IsTaxRegistered\": null,\r\n\t\"IsInclusiveTax\": false\r\n\t}\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/Debtor",
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => "",
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 30,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => "PUT",
  CURLOPT_POSTFIELDS => "{\r\n\t\"Id\": \"{[!MzAwLUEwMDI!]}\",\r\n\t\"CompanyName\": \"AutoCount On The Go\",\r\n\t\"RegisterNo\": \"\",\r\n\t\"Description\": \"AOTG Team\",\r\n\t\"InvoiceAddress\": {\r\n\t  \"Contact\": \"Mr.Lee\",\r\n\t  \"Fax\": \"\",\r\n\t  \"Phone\": \"02111373\",\r\n\t  \"Address1\": \"1/2, PINE STREET,\",\r\n\t  \"Address2\": \"CENTURY ROAD,\",\r\n\t  \"Address3\": \"SELANGOR\",\r\n\t  \"Address4\": \"50000 MALAYSIA\"\r\n\t},\r\n\t\"DeliverAddress\": {\r\n\t  \"Contact\": \"Mr.Tan\",\r\n\t  \"Fax\": \"\",\r\n\t  \"Phone\": \"02111373\",\r\n\t  \"Address1\": \"1/2, PINE STREET,\",\r\n\t  \"Address2\": \"Delivery CENTURY ROAD,\",\r\n\t  \"Address3\": \"SELANGOR\",\r\n\t  \"Address4\": \"50000 MALAYSIA\"\r\n\t},\r\n\t\"CreditTerm\": \"C.O.D.\",\r\n\t\"CreditLimit\": 30000,\r\n\t\"WebURL\": \"\",\r\n\t\"EmailAddress\": \"\",\r\n\t\"IsActive\": true,\r\n\t\"CurrencyCode\": \"MYR\",\r\n\t\"IsTaxRegistered\": null,\r\n\t\"IsInclusiveTax\": false\r\n\t}\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;
}

Code is not available


Response

Response Successful HTTP Request

200 OK

Response Successful Body

{
    "Id": "a4b6c-4b61-8e79-61edc6",
    "Name": "UpdateDebtor",
    "StartTimestamp": "2019-02-28T02:16:50.7451568Z",
    "EndTimestamp": "2019-02-28T02:16:50.7451568Z"
}


See Also AOTG API


Go to menu

  Go to top
  Resources For AutoCount Software Developers