I would like to specify an API version when I call a @RestResource via an API. Is that possible?
Why
For some reason, our Spring '19 sandbox is having a weird issue, and I'd like to fix this before production becomes Spring. We put in a support ticket, but I wonder if someone else has hit this issue and solved it, or if it's a known issue that will be fixed before release.
We have enabled Enterprise Territory Management in our org, and we have a class MyRestResource
that references UserTerritory2Association
. MyRestResource
is a @RestResource
. When we hit the resource in a unit test, it works just fine, but when we hit it via REST API, it fails.
This works in Winter '19, but not in Spring '19 sandbox.
Here's a minimally-viable failure of this test.
@RestResource(urlMapping='/my-resource')
global class MyRestResource {
@HttpPost
global static void doIt() {
UserTerritory2Association assoc = null;
}
}
Here's a similar issue:
(Which version of a managed package @RestResource class is used to handle a REST request?)
/services/data/v43.0/tooling
. Also, what is the API version for the class that defines the REST resource set to?