2

So we have a number of mapped urls, and up until recently they were working fine. We recently noticed that our requests are inconsistently being routed to the wrong APIs.

Example:

@restResource(urlMapping='/api/v1/param1/*/param2/*')

and

@restResource(urlMapping='/api/v1/param1/*/param2/*/param3/*')

As you can see, the format of the API urls is similar, but different. The problem we are encountering is that if we attempt to hit the second API with the following request URL

[salesforce org]/services/apexrest/api/v1/param1/123/param2/abc/param3/xyz

Salesforce is sometimes interpreting the request parameters as

param1 = 123/param2/abc
param3 = xyz

Which is the first API URL, when it should be utilizing the second mapped API URL giving us the parameters

param1 = 123
param2 = abc
param3 = xyz

This functionality seems to contradict the documentation which states

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.

This isn't the only inconsistency we are finding in our API calls; for example, we are also getting METHOD_NOT_ALLOWED errors for API classes that absolutely contain those methods. However, This also seems to relate to the same routing issue.

It is worth noting, similar issues have occurred as far back as 2014, I was just hoping a more recent solution may have popped up: Rest Routing with Multiple Wildcards / Supporting REST Routing for Nested Resources

0

Try to compile Apex Classes and see if this fix the issue Otherwise contact Salesforce support

  • We tried compiling classes with inconsistent results. We have contacted support for now, fingers crossed. – zgc7009 Apr 10 '17 at 13:48

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.