I have a question about the urlmapping property on a REST class. For the moment I have 3 REST classes with following urlmappings:
- REST1.cls @RestResource(urlmapping='/invoices/*/')
- REST2.cls @RestResource(urlmapping='/invoices/*/totals/')
- REST3.cls @RestResource(urlmapping='/invoices/*/related/')
I have 3 types of corresponding REST urls:
- "/services/apexrest/invoices/due/" or "/services/apexrest/invoices/paid/"
- "/services/apexrest/invoices/{Salesforce Id}/totals/"
- "/services/apexrest/invoices/{Salesforce Id}/related/"
When I do the requests I get the following results:
- CORRECT "/services/apexrest/invoices/due/" maps to REST1.cls
- CORRECT "/services/apexrest/invoices/paid/" maps to REST1.cls
- INCORRECT "/services/apexrest/invoices/{Salesforce Id}/totals/" maps to REST1.cls (should map to REST2.cls)
- INCORRECT "/services/apexrest/invoices/{Salesforce Id}/related/" maps to REST1.cls (should map to REST3.cls)
When I look at the documentation I see that these are the rules followed:
- 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.
I would expect they map to the classes listed above. Can someone explain what is going wrong here?
UPDATE: I want to keep the logic of my REST url's, the sequence of the parameters and url structure is in line with usability best practises, and I believe the salesforce url mapping should be capable of this.