@InvocableMethod annotation is not allowing to pass two parameters. i want to pass parameter in my rest api can any one plz tell me where i need to do changes in my code here my code

public class TwilioSendSMS {
    @InvocableMethod(label='Send Message')
    public static void sendSms(){            
        String phNumber ;        
        String accountSid = 'xxxxxxxxxxxxxxxxxxxxx';        
        String token = 'xxxxxxxxxxxxxxxxxxx';        
        String fromPhNumber = '+19xxxxxxxxxx';           
        String smsBody;       
        HttpRequest req = new HttpRequest();        
        String VERSION  = '3.2.0';              
        req.setHeader('Accept', 'application/json');        
        req.setHeader('Accept-Charset', 'utf-8');        
        req.setHeader('Authorization','Basic '+EncodingUtil.base64Encode(Blob.valueOf(accountSid+':' +token))); 
        req.setHeader('Content-Type', '"application/x-www-form-urlencoded"'); 
        Http http = new Http();        
        HTTPResponse res = http.send(req);        
        System.Debug('Message sending Successful');        
            System.Debug('Message sending Unsuccessful');
New contributor
Rajesh is a new contributor to this site. Take care in asking for clarification, commenting, and answering. Check out our Code of Conduct.
  • you can have a wrapper class, and mark each property with @InvocableVariable annotation, then in your method you ask for a list of wrappers, take a look at this post
    – McCubo
    Jun 22 at 7:18
  • Thanks Nagendra Singh.. if I just add wrpper class, can you suggest me how can I modify my code
    – Rajesh
    Jun 22 at 11:05

1 Answer 1


First you need to create a new apex class, with as many attributes as parameters you need to pass to your @InvocableMethod method:

public class Requests {
  public String param1;
  public String param2;

then all you need to do is change your method's signature to take a list of Requests objects, something like this:

@InvocableMethod(label='Send Message')
public static void sendSms(List<Requests> reqs){
   // access properties values
   String val1 = reqs.get(0).param1;
   String val2 = reqs.get(0).param2;

And last, when you go to your flow, and select your apex action, you can enable the parameters you need to pass: enter image description here

Hope this help!

  • Thanks McCubo great help
    – Rajesh
    Jun 22 at 11:55

Your Answer

Rajesh is a new contributor. Be nice, and check out our Code of Conduct.

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.