+ Start a Discussion
Iqra TechIqra Tech 

getting error : - Constructor not defined: need help

public class My_2nd_Api {
    
    Public static void Insert_Records(){
   
        
        List<Opportunity> oppbatch=[select id,name,stagename, (select id,name from OpportunityLineItems), (Select contact.firstname,contact.lastname,contact.Email,contact.Phone from OpportunityContactRoles) from Opportunity];
        system.debug('oppbatch List query.. '+oppbatch);
        
List<OppWrapper> oppWrapperVarList = new List<OppWrapper>();
for(Opportunity opp : oppbatch) 
{
 system.debug(opp.OpportunityLineItems);
 OppWrapper oppwrappervar= new OppWrapper(opp.name,opp.StageName,opp.Edition__r.name,opp.Sub_Allocation_Name__r.name,opp.Account.name,opp.Account.Website,                                         opp.Account.BillingCountry,opp.Account.BillingState,opp.Account.BillingCity,opp.Account.BillingStreet,
                                         opp.Account.BillingPostalcode);         
   
    for(OpportunityLineItem li : opp.OpportunityLineItems)
    {    
        oppwrappervar (li.Unique_id__c,li.Product_Sub_Category_New__c,li.Stand_Number_s__c,li.Hall_s__c,li.Type_of_Stand__c,li.Stand_Depth__c,
                       li.Stand_Width__c,li.Contractual_Sq_M__c);
    }
   /* for(OpportunityContactRole ocr : opp.OpportunityContactRoles)
    {
        co.Ocr_Id__c =ocr.id;
        co.Ocr_Name__c=ocr.contact.name;
        co.Ocr_First_Name__c=ocr.contact.firstname;
        co.Ocr_Last_Name__c=ocr.contact.lastname;
        co.Ocr_contactEmail__c=ocr.contact.Email;
        co.Ocr_contactPhone__c=ocr.contact.Phone;
        co.Ocr_Salutation__c=ocr.contact.Salutation;
    }*/
    
  oppWrapperVarList.add(oppwrappervar);
//OppWrapper oppwrappervar=new OppWrapper(oppbtch.Edition_Name__c,oppbtch.Opportunity_Id__c,oppbtch.Opportunity_Name__c,oppbtch.Opportunity_Stage__c,oppbtch.Stand_No__c,oppbtch.Banner_name__c);
//oppWrapperVarList.add(oppwrappervar);
}
 string jsonbody=Json.serialize(oppWrapperVarList);
        system.debug('Json body---->'+jsonbody);
        
        Http http = new Http();
        HttpRequest request = new HttpRequest();
        //request.setEndpoint('http://fpdatamap.salesforceoutsourcing.in/api/FPDatas');
        request.setEndpoint('http://sfdata.iqratechnology.com/api/sf_data');

        request.setMethod('POST');
        request.setHeader('Content-Type','application/json');
        //request.setHeader('Content-Type','multipart/form-data; boundary=----WebKitFormBoundary7MA4YWxkTrZu0gW');
        //request.setHeader('Authorization','Bearer '+ AuthorizationToken);
//request.setBody('[{ "RecordId": "456","RecordName": "moosa traders pvt ltd / The Big 5 Construct Egypt 2018 /  / 093061123", "EventName": "a2JD0000001ns6uMAA U", "RecordStage": "Test Stage Amjad","BannerName": "Test Banner Amjad","StandNo": "Test Stand Amjad"}]');
        request.setBody(jsonbody);
        
       HttpResponse response = http.send(request);
        system.debug('Response body '+ response.getBody());
if (response.getStatusCode() != 201) {
    System.debug('The status code returned was not expected: ' +
        response.getStatusCode() + ' ' + response.getStatus());
} else {
    System.debug(response.getBody());
}
        
        
    }
    
    public class OppWrapper
    {
        public String SFDC_RecordID {get;set;}
        public String SFDC_RecordName {get;set;}
        public String SFDC_RecordStage {get;set;}
        public String SFDC_EventName {get;set;}
        public String Stan_Sub_Allocation_Name {get;set;}
        public String Acount_Long_Name {get;set;}
        public String Web_Site {get;set;}
        public String Country {get;set;}
        public String Country_State {get;set;}
        public String City {get;set;}
        public String Street {get;set;}
        public String Post_code {get;set;}
        public String SFDC_Record_Unique_ID {get;set;}
        public String Product_Subcategory {get;set;}
        public String Stand_no {get;set;}
        public String Hall {get;set;}
        public String Type_of_Stand {get;set;}
        public Decimal Height {get;set;}
        public Decimal Width {get;set;}
        public Decimal Contractual_Sq_M {get;set;}
        public OppWrapper(String SFDC_RecordID,String SFDC_RecordName,String SFDC_RecordStage,String SFDC_EventName,String Stan_Sub_Allocation_Name,
                          String Acount_Long_Name,String Web_Site,String Country,String Country_State,String City,String Street,String Post_code,
                          String SFDC_Record_Unique_ID,String Product_Subcategory,String Stand_no,String Hall,String Type_of_Stand,Decimal Height,
                          Decimal Width,Decimal Contractual_Sq_M)
        {
            this.SFDC_RecordID =SFDC_RecordID;
            this.SFDC_RecordName =SFDC_RecordName;
            this.SFDC_RecordStage =SFDC_RecordStage;
            this.SFDC_EventName=SFDC_EventName;
            this.Stan_Sub_Allocation_Name=Stan_Sub_Allocation_Name;
            this.Acount_Long_Name=Acount_Long_Name;
            this.Web_Site=Web_Site;
            this.Country=Country;
            this.Country_State=Country_State;
            this.City=City;
            this.Street=Street;
            this.Post_code=Post_code;
            this.SFDC_Record_Unique_ID=SFDC_Record_Unique_ID;
            this.Product_Subcategory=Product_Subcategory;
            this.Stand_no=Stand_no;
            this.Hall=Hall;
            this.Type_of_Stand=Type_of_Stand;
            this.Height=Height;
            this.Width=Width;
            this.Contractual_Sq_M=Contractual_Sq_M;
            
            
            
        }
    }
    
}


Getting error on bold line error is :-

Line 13 : Constructor not defined: [My_2nd_Api.OppWrapper].<Constructor>(String, String, String, String, String, String, String, String, String, String, String)
Line 19:  Method does not exist or incorrect signature: void oppwrappervar(String, String, String, String, Id, Decimal, Decimal, Decimal) from the type My_2nd_Api
Anant KamatAnant Kamat
You have defined only one constructor in OppWrapper which is accepting all the variables which is not the case with Line 13. Either you pass all the required variables else define a new constructor with only those variables required.