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
The Ajay GuptaThe Ajay Gupta 

Apex Rest Webservice is not working as documented in Force.com Apex Code Developer's Guide V34.0

Ihave two Apex Rest Webservice Rest1 & Rest2.

Rest1 webservice Apex class has annotation @RestResource(urlMapping='/ApexRest')

Rest2 webservice Apex class has annotation @RestResource(urlMapping='/ApexRest/*') which is saved last.

But when I tried to call the Apex Rest webservice using url url/service/apexrest/ApexRest it calls Rest1 not Rest 2 which is last saved. So I am getting confused, Is salesforce documentation is right?

An extract from Page No: 255 Force.com Apex Code Developer's Guide V34.0 summer'15 documentation:

The URL patterns URLpattern and URLpattern /* match the same URL. If one class has a urlMapping of URLpattern and another class has a urlMapping of URLpattern /*, a REST request for this URL pattern resolves to the class that was saved last.
StackExchange Question Link : Link (http://salesforce.stackexchange.com/questions/83942/apex-rest-webservice-is-not-working-as-documented-in-force-com-apex-code-develop)
pconpcon
I believe in order for that to occur, your Rest1 urlMapping would have to be '/ApexRest/'  otherwise the regex that is being applied to the URI would not match both.  If they are saying they match i the documentation, then the documentation is wrong.