4

I'm trying to update a Class' API version within a managed package.

The function is as follows:

@HttpPut
global static String uploadNewAttachment(RestRequest req) {

When I try to bump the Class version from 23.0 (old I know) up to anything above 30, I get the error: HttpPut methods do not support parameter type of System.RestRequest at line 5 column 26

But if I clear out the param and use RestRequest/RestResponse instead, I receive: Error: Compile Error: Global/WebService identifiers cannot be removed from managed application: Method String uploadNewAttachment(System.RestRequest) at line -1 column -1

Is there any way around this?

1
  • 2
    Personally, given that support for old API versions is in the process of being withdrawn, I would be raising this with Salesforce Support (I presume you work for a partner).
    – Phil W
    Commented Feb 11, 2021 at 20:52

1 Answer 1

1

You should be able to remove the @HttpPut annotation, and replace it with @deprecated instead, and then use the new version:

@deprecated
global static String uploadNewAttachment(RestRequest req) {
  return 'Not supported';
}
@HttpPut
global static String uploadNewAttachment() {
  RestRequest req = RestContext.request;
  // Rest of original code here

This should allow you to upload the new version without any problems, and (eventually) you should be able to remove @deprecated methods. This annotation will also prevent future subscribers from accidentally calling the new method.

6
  • Are you certain you can remove the annotation from the global? Is this not deemed part of the overall signature of the method for managed package purposes? (I also wonder why REST API classes and methods are always shown as global and whether this is actually required? The documentation only implies it via the examples...)
    – Phil W
    Commented Feb 11, 2021 at 22:55
  • (Just tried it - they do have to be global after all...)
    – Phil W
    Commented Feb 11, 2021 at 22:57
  • 1
    Thanks! Though I'm now receiving: Previously annotated identifier with @HttpPut must still be annotated
    – McD
    Commented Feb 11, 2021 at 23:15
  • 2
    @PhilW Hmm. I was assuming it was possible. I guess this thing is really locked down. Sounds like Partner Support needs to get involved after all.
    – sfdcfox
    Commented Feb 11, 2021 at 23:17
  • @McD See my previous comment.
    – sfdcfox
    Commented Feb 11, 2021 at 23:18

You must log in to answer this question.

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