2

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 Feb 11 at 20:52
0

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 Feb 11 at 22:55
  • (Just tried it - they do have to be global after all...) – Phil W Feb 11 at 22:57
  • 1
    Thanks! Though I'm now receiving: Previously annotated identifier with @HttpPut must still be annotated – McD Feb 11 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 Feb 11 at 23:17
  • @McD See my previous comment. – sfdcfox Feb 11 at 23:18

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.