2

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?)

3
  • Have you tried varying the API version defined in the REST resource URL? E.g. /services/data/v43.0/tooling. Also, what is the API version for the class that defines the REST resource set to? Commented Jan 9, 2019 at 19:56
  • @DanielBallinger The API version of the ApexClass is not different on either deployment. It's 43.0! That seems to be irrelevant to this particular bug. Commented Jan 10, 2019 at 15:10
  • @DanielBallinger Just tried adding v43.0 all over the path and it was all 404's. Commented Jan 10, 2019 at 15:13

0

You must log in to answer this question.