+ Start a Discussion
Lokesh KumarLokesh Kumar 

can somebody help me how to pass set of ID's in the REST API URL.

I am trying to pass Set of Ids in the where clause at the time of setEndPoint URL for more PFB.
Map<ID,ApexClass> apexclassName 		= new Map<Id,ApexClass>([select id,name from ApexClass where NamespacePrefix = null]);
        Map<ID,ApexTrigger> apexTriggerName 	= new Map<ID,ApexTrigger>([select id,name from ApexTrigger where NamespacePrefix = null]);
        Set<ID> apexandTriggerID = new Set<Id>();
        apexandTriggerID.addAll(apexTriggerName.keySet());
        apexandTriggerID.addAll(apexclassName.keySet());
        HttpRequest req = new HttpRequest();
        req.setHeader('Authorization', 'Bearer ' + UserInfo.getSessionID());
        req.setHeader('Content-Type', 'application/json');
        req.setEndpoint(URL.getSalesforceBaseURL().toExternalForm()+'/services/data/v37.0/tooling/query/?q=Select+ApexClassorTriggerId,NumLinesCovered,NumLinesUncovered,Coverage+from+ApexCodeCoverageAggregate+where+ApexClassorTriggerId+IN+(+'+apexandTriggerID+')');
        req.setMethod('GET');
        Http h = new Http();
        HttpResponse res = h.send(req);

the value which is getting assigned is like.

21:08:27:041 USER_DEBUG [12]|DEBUG|***System.HttpRequest[Endpoint=https://informatica--Lokesh.cs41.my.salesforce.com/services/data/v37.0/tooling/query/?q=Select+ApexClassorTriggerId,NumLinesCovered,NumLinesUncovered,Coverage+from+ApexCodeCoverageAggregate+where+ApexClassorTriggerId+IN+(+{01p550000001F7QAAU, 01p550000001F7RAAU, 01p550000001F7SAAU, 01p550000001F7TAAU, 01p550000001F7UAAU, 01p550000001F7VAAU, 01p550000001F7WAAU, 01p550000001F7XAAU, 01p550000001F7YAAU, 01p550000001F7ZAAU, ...}), Method=GET]