function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Sri Hari NadendlaSri Hari Nadendla 

Number of parameters exceeds maximum: 32

Hello all,

I am unable to insert more than 32 parameters in @httpPost method Please suggest me a better way in order to insert more parameters
Below Is my code:
@RestResource(urlMapping='/Students/*')
global with sharing class Studnets {

   
    
     @HttpPost
    global static String doPost(Integer Max,String ConcurrentAsyncGetReportInstances,String ConcurrentSyncReportRuns,Integer Max1,
    Integer Remaining,Integer Remaining1,String DailApiRequest,Integer DAPIRemaining,Integer DAPiMax,String Ant,Integer AntMax,
    Integer AntRemaining,String App,Integer AppMax,Integer AppRemaining,String DataloaderBulk,Integer DMax,Integer DRemaining,String DPartner,
    Integer DPMax,Integer DpRemaining,String FIde,Integer Fmax,Integer FRemaining,String SFMD,Integer SFMDMax,Integer SFMDRemaining,String SFTouch,Integer SFTMax,
    Integer SFTRemaining,Integer SFOMax,Integer SFORemaining,String SFOutlook)
     {
        System.debug('Entering in to APIUSAGE__c');
        APIUSAGE__c  st = new   APIUSAGE__c();
        st.ConcurrentAsync__c=ConcurrentAsyncGetReportInstances;
        st.ConcurrentSync__c=ConcurrentSyncReportRuns;
        st.Async_Max__c=Max;
        st.Max__c=Max1;
        st.SyncRemaining__c=Remaining;
        st.Async_Remaining__c=Remaining1;
        st.DailyApiRequests__c=DailApiRequest;
        st.DAPIRemaining__c=DAPIRemaining;
        st.DAPiMax__c=DAPiMax;
        st.Ant_Migration_Tool__c=Ant;
        st.Ant_Max__c=AntMax;
        st.Ant_Remaining__c=AntRemaining;
        st.App_Name__c=App;
        st.App_Max__c=AppMax;
        st.App_Remaining__c=AppRemaining;
        st.Dataloader_Bulk__c=DataloaderBulk;
        st.DMax__c=DMax;
        st.DRemaining__c=DRemaining;
        st.Dataloader_Partner__c=DPartner;
        st.DPMax__c=DPMax;
        st.DpRemaining__c=DpRemaining;
        st.ForceIDE__c=FIde;
        st.FMax__c=Fmax;
        st.FRemaining__c=FRemaining;
        st.SFMD__c=SFMD;
        st.SFMDMax__c=SFMDMax;
        st.SFMDRemaining__c=SFMDRemaining;
        st.SFTouch__c=SFTouch;
        st.SFTMax__c=SFTMax;
        st.SFTRemaining__c=SFTRemaining;
        st.SFOMax__c=SFOMax;
        st.SFOutlook__c=SFOutlook;
        st.SFORemaining__c=SFORemaining;
        
        
        
        insert st;
        return st.Id;
    }
    
    
 
}
Best Answer chosen by Sri Hari Nadendla
Purushotham YellankiPurushotham Yellanki
Hi,

Try using a Wrapper instead passing each parameter in a Method. Below is the sample Code

------------------------------------------------------------------------------
@RestResource(urlMapping='/Students/*')
global with sharing class Studnets {
    @HttpPost
    global static String doPost(Studnets.testWrapper wrpVals) {
        System.debug('Entering in to APIUSAGE__c');
        if (wrpVals != null) {
            APIUSAGE__c  st = new   APIUSAGE__c();
            st.ConcurrentAsync__c = wrpVals.ConcurrentAsyncGetReportInstances;
            st.ConcurrentSync__c = wrpVals.ConcurrentSyncReportRuns;
            st.Async_Max__c = wrpVals.Max;
            st.Max__c = wrpVals.Max1;
            
            insert st;
            return st.Id;        
        }
    }
    //Wrapper class to accept all input parameters
    public class testWrapper {
        Public Integer Max;
        Public String ConcurrentAsyncGetReportInstances;
        Public String ConcurrentSyncReportRuns;
        Public Integer Max1;
    }
}
------------------------------------------------------------------------------

All Answers

Purushotham YellankiPurushotham Yellanki
Hi,

Try using a Wrapper instead passing each parameter in a Method. Below is the sample Code

------------------------------------------------------------------------------
@RestResource(urlMapping='/Students/*')
global with sharing class Studnets {
    @HttpPost
    global static String doPost(Studnets.testWrapper wrpVals) {
        System.debug('Entering in to APIUSAGE__c');
        if (wrpVals != null) {
            APIUSAGE__c  st = new   APIUSAGE__c();
            st.ConcurrentAsync__c = wrpVals.ConcurrentAsyncGetReportInstances;
            st.ConcurrentSync__c = wrpVals.ConcurrentSyncReportRuns;
            st.Async_Max__c = wrpVals.Max;
            st.Max__c = wrpVals.Max1;
            
            insert st;
            return st.Id;        
        }
    }
    //Wrapper class to accept all input parameters
    public class testWrapper {
        Public Integer Max;
        Public String ConcurrentAsyncGetReportInstances;
        Public String ConcurrentSyncReportRuns;
        Public Integer Max1;
    }
}
------------------------------------------------------------------------------
This was selected as the best answer
Sri Hari NadendlaSri Hari Nadendla
Hi Purushotham,

Thanks for Responding and thanks for the sample code you made my job easier .
anjali telikepallianjali telikepalli

Hi @Purushotham Yellanki,
 i have tried above code it's working for me, how to write test class for above class.
can you please help me how to write test class for it
Thanks in advance..