-
Book Overview & Buying
-
Table Of Contents
-
Feedback & Rating
Mastering Apex Programming - Second Edition
By :
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
global static String getExampleResponse...
Change the font size
Change margin width
Change background colour