Apex Rest Logging
@RestResource(urlMapping='/Account/*')
global with sharing class MyRestResource {
@HttpPost
global static String doPost(String name, String phone, String website) {
String transactionId = Triton.instance.startTransaction();
RestRequest req = RestContext.request;
RestResponse res = Restcontext.response;
Log.instance.integrationLog(TritonTypes.Type.AccountIntegration, /* type */
TritonTypes.Area.Accounts, /* functional area */
'Initiating new account creation', /* summary */
String.format('POST received with name = {0}, phone = {1}, website = {2}',
new String[]{name, phone, website}), /* formatted details */
req, /* request */
res); /* response */
try {
Account account = new Account();
account.Name = name;
account.phone = phone;
account.website = website;
//(optional) perform some other processing asynchronously,
//passing an existing transaction Id
AccountProcessing.doAsyncProcessing(account, transactionId);
insert account;
return account.Id;
} catch(Exception e) {
//uh oh, something went wrong, let's log this!
Triton.instance.error(e);
}
return null;
}
}
The Result
Last updated