1

I developed a REST API for my managed package which works correctly when tested for development in my scratch org but also as a released managed package.

Recently I made minor changes to it - like simply adding the support for an additional query string parameter, nothing extraordinary - and, although it works just fine both on my scratch org and on my packaging org, it doesn't when tested as a beta package. But it's not the change that doesn't work, it's the whole service.

I get a 403 HTTP status code with the payload below whenever I call any of my endpoints:

[
  {
    "errorCode": "FORBIDDEN",
    "message": "Request blocked due to package versioning restrictions"
  }
]
2
  • Did you change a global Apex method signature implementing the REST API?
    – David Reed
    Commented Mar 27, 2020 at 13:07
  • I didn't. As I said I really changed a minor thing. At this point I'm not even sure I have ever tested the REST API with my previous beta packages, but it would really be strange. Maybe I should try and test some older beta version for comparison.
    – shillem
    Commented Mar 27, 2020 at 13:10

1 Answer 1

0

I figured out what happened. Sadly, if you got to that point there's no solution for it, just a workaround.

You will encounter this error if you first package a global class similar to this.

@RestResource(urlMapping='/my-pretty-path/*')
global with sharing class MyPrettyRestHandler {

    @HttpGet
    global static void doGet() {
        // My pretty logic
    }

}

Beautiful, isn't it? But we all know the rules: once a global class gets packaged and the package is released that class cannot be retired anymore... well, kind of... there's still a painful way you can look into if you really want to (Revert a managed package to a beta version).

However there's literally NO WAY to EVER amend your mistakes if you persevere in the error... enter the @deprecated annotation. In the context of a REST handling class this useful - cough - annotation will help you achieve the perfect path nuking. You just add it like so:

@RestResource(urlMapping='/my-pretty-path/*')
@deprecated
global with sharing class ApplicationRestProvider {
    ...

Next you create a new package version (or simply a new version?) and you can high-five yourself. You just made my-pretty-path unusable to time indefinite. The solution for you now is the one of choosing a different path and ask all of your customers using that REST API path to migrate to a different path. Isn't that great? Well, in the end it's me who wanted it...

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .