The @RestResource annotation is used at the class level and enables you to expose
an Apex class as a REST resource.
These are some considerations when using this annotation:
- The URL mapping is relative to https://instance.salesforce.com/services/apexrest/.
- A wildcard character (*) may be used.
- The URL mapping is case-sensitive. A URL mapping for my_url will only match a REST resource
containing my_url and not My_Url.
- To use this annotation, your Apex class must be defined as global.
URL Guidelines
URL path mappings are as
follows:
- The path must begin with a '/'
- If an '*' appears, it must be preceded by '/' and followed by
'/', unless the '*' is the last character, in which case it need not
be followed by '/'
The rules for mapping URLs are:
- An exact match always wins.
- If no exact match is found, find all the patterns with wildcards
that match, and then select the longest (by string length) of those.
- If no wildcard match is found, an HTTP response status code 404
is returned.
The URL for a namespaced classes contains the namespace. For
example, if your class is in namespace abc and the class is mapped to your_url, then the API URL is modified as follows: https://instance.salesforce.com/services/apexrest/abc/your_url/. In the case of a URL collision, the namespaced class is always
used.