Skip to content

Instantly share code, notes, and snippets.

@anilsomasundaran
Created January 13, 2019 17:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anilsomasundaran/1730563c9db94e414b01c1d40e0b0284 to your computer and use it in GitHub Desktop.
Save anilsomasundaran/1730563c9db94e414b01c1d40e0b0284 to your computer and use it in GitHub Desktop.
@RestResource(urlMapping='/Accounts/*')
global with sharing class AccountManager {
@HttpGet
global static Account getAccountById() {
RestRequest request = RestContext.request;
String accountId = request.requestURI.substring(
request.requestURI.lastIndexOf('/')+1);
Account result = [SELECT Name,AccountNumber,Type,BillingAddress
FROM Account
WHERE Id = :accountId];
return result;
}
@HttpPost
global static ID createAccount(String Name,String accountNumber) {
Account thisAccount= new Account(
Name=Name, AccountNumber = accountNumber);
insert thisAccount;
return thisAccount.Id;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment