function readOnly(count){ }
Don't have an account?
Search for an answer or ask a question of the zone or Customer Support.
You need to sign in to do that
Sign in to start searching questions
Signup for a Developer Edition
Sign in to start a discussion
@RestResource(urlMapping='/Account/*') global with sharing class MyRestResource { @HttpDelete global static void doDelete() { RestRequest req = RestContext.request; RestResponse res = RestContext.response; String accountId = req.requestURI.substring(req.requestURI.lastIndexOf('/')+1); Account account = [SELECT Id FROM Account WHERE Id = :accountId]; delete account; } @HttpGet 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; } @HttpPost global static String doPost(String name, String phone, String website) { Account account = new Account(); account.Name = name; account.phone = phone; account.website = website; insert account; return account.Id; } }
{ "records" :[{ "attributes" : {"type" : "Account", "referenceId" : "ref1"}, "name" : "SampleAccount1", "phone" : "1234567890", "website" : "www.salesforce.com", "numberOfEmployees" : "100", "industry" : "Banking", "Contacts" : { "records" : [{ "attributes" : {"type" : "Contact", "referenceId" : "ref2"}, "lastname" : "Smith", "Title" : "President", "email" : "sample@salesforce.com" },{ "attributes" : {"type" : "Contact", "referenceId" : "ref3"}, "lastname" : "Evans", "title" : "Vice President", "email" : "sample@salesforce.com" }] } },{ "attributes" : {"type" : "Account", "referenceId" : "ref4"}, "name" : "SampleAccount2", "phone" : "1234567890", "website" : "www.salesforce.com", "numberOfEmployees" : "52000", "industry" : "Banking", "childAccounts" : { "records" : [{ "attributes" : {"type" : "Account", "referenceId" : "ref5"}, "name" : "SampleChildAccount1", "phone" : "1234567890", "website" : "www.salesforce.com", "numberOfEmployees" : "100", "industry" : "Banking" }] }, "Contacts" : { "records" : [{ "attributes" : {"type" : "Contact", "referenceId" : "ref6"}, "lastname" : "Jones", "title" : "President", "email" : "sample@salesforce.com" }] } }] }
Yes, You can use more than one @post method in REST API. But make sure that name of Parameters or no of parameters must be different.
You can also create more than one class with same URLResource but while making callout server will hit that class which has the latest modified date.
Visit the given link for more info . https://developer.salesforce.com/page/Creating_REST_APIs_using_Apex_REST
Cheers :)
Thanks,
Amit Singh.
You can't use multiple @post methods in the same class but you can use in different class in REST API.
see the example Thank you.