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
Nirav_ShahNirav_Shah 

Invalid type for Http* method: HttpGet

Hi Folks,

I am trying to create the API which can fetch the data from Salesforce and send it to an external system. For that, I am using REST web services HttpGet.
Below is the code I am trying to write.
@RestResource(urlMapping='/api/*')
global with sharing class DetailsController{
   
    @HttpGet
    global static List<Wrapper1> getDetails() {
        RestRequest req = RestContext.request;
        RestResponse res = RestContext.response;
        
        string GO, ID;
        
		if(!string.isEmpty(req.params.get('GO'))){
			GON = req.params.get('GO');
		}
		else{
			throw new Utility.applicationException('GO Cannot be null');
		}
		
		if(!string.isEmpty(req.params.get('ID'))){
			UCMID = req.params.get('ID');
		}
		else{
			ID = '';
		}
        
        List<Wrapper1> Details = fetchDetails(GO, ID);
        return Details;
    }
The Wrapper1 hear is the Wrapper class which includes another wrapper class Wrapper2 in it.

Wrapper1
global class Wrapper1 {
    @AuraEnabled
    public string GO;
    @AuraEnabled
    public string Name;
    @AuraEnabled
    public string Address;
    @AuraEnabled
    public List<Wrapper2> Fsets;
    public class OrderTrackingDetail{
        @AuraEnabled public string Carrier=System.label.CCP_NotAvailableValue;
        @AuraEnabled public string TrackingID=System.label.CCP_NotAvailableValue;
        @AuraEnabled public string fSetNum;
        @AuraEnabled public string trackingURL;
    }
}
Wrapper2
public class Wrapper2 implements Comparable {
	
    public string addressCity;
    @AuraEnabled
    public string addressLine1;
    @AuraEnabled
    public string addressLine2;
    @AuraEnabled
    public string addressLise3;
    public string addressLine4;
    public string addressState;
    public string addressZip;
    public string Name;
    public string Country;
    @AuraEnabled
    public List<Object> object1 = new List<Object>();
    @AuraEnabled
    public List<Object> object2 = new List<Object>();
    public Integer compareTo(Object objToCompare) {
        integer val1 = integer.valueOf(//something);
        integer val2 = integer.valueOf(((Wrapper2)objToCompare).//something);
        if (val1 == val2) 
            return 0;
        if (val1 > val2) 
            return 1;
        return -1;
    }
}

When I am trying to write the gate method I am getting the below error.
Invalid type for Http* method: LIST.Wrapper1.LIST.Wrapper2.LIST.Object
How to solve this error.? Please help

Thanks
Nirav
 
JitukawaleJitukawale
Hi Nirav,

Use "Global" access modifier for Wrapper1, Wrapper2, and all public variables. This will resolve your problem.

Thanks,
Jitendra Kawale.

 
Nirav_ShahNirav_Shah
Hi Jitukawale,

Thanks for the suggestion, I have tried this but didn't get the success

Thanks