Defining endpoints
All Apex classes exposed as web services need to be defined as global in scope to ensure that they are visible to outside users. To define a class as an Apex REST service, we must annotate the class with the @RestResource
annotation and provide a URL mapping. The following code snippet shows the definition of an Apex class for the /Example
endpoint:
@RestResource(urlMapping = '/Example/*') global with sharing class ApexRESTExample { Â Â Â Â }
Within the class, we must then define methods and annotate them with the appropriate method annotation to expose them as an HTTP method. These methods must be static as they are called without a specific instance of the class instantiated. In the following code block, we can see some basic Apex methods that have all the provided annotations:
@RestResource(urlMapping = '/Example/*') global with sharing class ApexRESTExample { Â Â Â Â Â Â Â Â @HttpGet...