Many businesses today are leveraging Salesforce to run their day-to-day operations. With its diverse capabilities, it can easily help manage customer relationships, develop applications, and conduct business intelligence analysis. For applications that need access to the Salesforce platform, one of the most popular options is to use the Apex RESTful web service.
Let’s see an example about how to consume a Salesforce api rest, for instance:
/services/apexrest/
The example shows how to authenticate using username and password to get the access token and then how to do a request to this Salesforce web service:
@RestResource(urlMapping='/hellorest')
global class HelloRest {
@HttpPost
global static String echo(String name) {
String echo = 'Hi, '+name;
System.debug('Echo: '+echo);
return echo;
}
}
See the code from Github https://github.com/andrescanavesi/salesforce-apex-rest