AOTG API: Delete Debtor

Revision as of 06:32, 28 February 2019 by DanielY (talk | contribs)

Draft

Delete Debtor

Delete a specific Debtor.

  • debtorId is a unique identifier created in AOTG.
  • See Get List of Debtor on how to obtain Id (that is created in AOTG).

API Method

Http Method: DELETE
Method: /api/public/v1/Debtor/{debtorId} 
Content-Type: application/json
Parameters: 

Code Snippets

<?php

$request = new HttpRequest();
$request->setUrl('http://aotg.cloud:8080/api/public/v1/Debtor/{[%21MzAwLUEwMDE%21]}');
$request->setMethod(HTTP_METH_DELETE);

$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/Debtor/{[%21MzAwLUEwMDE%21]}");
var request = new RestRequest(Method.DELETE);
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/Debtor/{[%21MzAwLUEwMDE%21]}",
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => "",
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 30,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => "DELETE",
  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;
}

Code is not available


Response

AOTG Cloud Server returns successful response when the request has been performed.
But this response does not indicate the status of the delete.
As such, use RESULT method to acquire the status.

Response Successful HTTP Request

200 OK

Response Successful Body

{
    "Id": "f0268032-c161-4548-a74a-adb7143274a6",
    "Name": "DeleteDebtor",
    "StartTimestamp": "2019-02-28T05:02:28.7462812Z",
    "EndTimestamp": "2019-02-28T05:02:28.7462812Z"
}

Get Status of the DELETE

Response

Response Successful HTTP Request

200 OK

Response Successful Body

{
    "RequestId": "87e028c2-f9f1-40ef-8b76-e3fd82d298ae",
    "Status": "Completed"
}

Response

Response Successful HTTP Request

200 OK

Response Successful Body

{
    "RequestId": "11eaf086-6f26-4f47-9352-6b72b94fe320",
    "Status": "Failed"
}

Use Result to find reason of failed

{

   "RequestId": "11eaf086-6f26-4f47-9352-6b72b94fe320",
   "RequestName": "DeleteDebtor",
   "HostName": "---",
   "IPAddress": "---",
   "RequestTypeName": null,
   "ResultJson": "{\"Message\":\"Debtor record not found (AccNo=300-A002).\",\"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-02-28T04:52:00.3825908Z",
   "ResultedTimestamp": null,
   "ProcessingInterval": 0.3498795,
   "InQueueInterval": null,
   "ResultFileURL": null

}



{

   "RequestId": "f0268032-c161-4548-a74a-adb7143274a6",
   "RequestName": "DeleteDebtor",
   "HostName": "---",
   "IPAddress": "---",
   "RequestTypeName": null,
   "ResultJson": "{\"Message\":\"Account in use, can't delete debtor.\",\"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-02-28T05:02:31.0804976Z",
   "ResultedTimestamp": null,
   "ProcessingInterval": 0.47969649999999997,
   "InQueueInterval": null,
   "ResultFileURL": null

}


See Also AOTG API


Go to menu

  Go to top
  Resources For AutoCount Software Developers