function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
inbox outbox 7inbox outbox 7 

How to make a REST call or Apex Web Service?

I need an example with the code. 
I just need to know how we send the Unique Message ID or 
Unique Record ID in the request.

Please provide me a code
Prateek Prasoon 25Prateek Prasoon 25
Here is the code posted below..You can check it out 



@RestResource(urlMapping='/v1/AccountMgmt/')
global class AccountMgmt{
    @httpGet
    global static Account doGetMethod(){
    Account acc= new Account();
    Map<String,String> paramsMap = RestContext.request.params;
    String accid=paramsMap.get('id');
    acc = [select id,name,AnnualRevenue from Account where Id =:accid];
    return acc;
    }
 
 
   @httpPost
    global static Account doPostMethod(String Name, Integer AnnualRevenue){
    Account acc= new Account(Name =name,AnnualRevenue = annualrevenue);
    insert acc;
    return acc;
    }
   @httpPut
    global static Account doPutMethod(String Name, Integer AnnualRevenue){
    Map<String,String> paramsMap = RestContext.request.params;
    String accid=paramsMap.get('id');
     Account acc= new Account(Name =name, AnnualRevenue = annualrevenue, Id =accid);
    update acc;

Kindly mark it as best answer if it helps.Thanks
PriyaPriya (Salesforce Developers) 

Hey 

Kindly refer this trailhead article which has explained the web service with example :- 

https://trailhead.salesforce.com/content/learn/modules/apex_integration_services/apex_integration_webservices

If this help, Kindly mark it as the best answer.

Regards,

Priya Ranjan