Below is the name of my method and argument of that method

private static void Callout(List<Id>cnt)

I am calling above method using following code

classname.Callout(cnt.id). //where cnt is contact cnt = new contact(LastName='test');

I am getting this error

Method does not exist or incorrect signature: class.Callout(Id)

Can you advice how else can I call that method?


If you want to construct a List which contains a single element, you can use curly brackets ({}):

ClassName.callout(new List<Id> { cnt.Id });
  • 1
    Thank you Adrian. I have tried above solution. still getting another error. Error now tells method is not visible classname.callout(List<Id>)
    – Aman
    May 10 '17 at 14:55
  • 1
    @Aman You can only call public methods... You could change the method declaration's access modifier from private to public.
    – Adrian Larson
    May 10 '17 at 14:56

You should keep some other things in mind as well like:

You should use naming conventions in your code like use camelCase for method names and variable names and CamelCase for class name

class ClassName{
    private static void callout(List<Id> cnt){
        /* Method logic here */

Rest is covered by @Adrian in the answer.


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.