Rest API Call for GET and POST

global with sharing class MyRestResource {

global static Account doGet() {
RestRequest req = RestContext.request;
RestResponse res = RestContext.response;
String accountId = req.requestURI.substring(req.requestURI.lastIndexOf(‘/’)+1);
Account result = [SELECT Id, Name, Phone, Website FROM Account WHERE Id = :accountId];
return result;

global static String doPost(String name,
String phone, String website) {
Account account = new Account();
account.Name = name; = phone; = website;
insert account;
return account.Id;


  1. GET – call following URL in workbench rest explorer””
  2. POST -“”

    JSON Format-

“name” : “Wingo Ducks”,
“phone” : “707-555-1234”,
“website” : “”



Need more help?

Hi there, was your problem or query resolved? If not & need more assistance, please do reach out to us at, we'll be more than delighted to help. Nanostuffs has 7+ years of extensive Salesforce & iOS/Android experience.
Holler Box