1

How can i get multiple values for same parameter for below rest request using Rest request method?

https://cs40.salesforce.com/services/apexrest/Membership?include=Membership:member&_include=Membership:organization&_include=Membership:service

0

You have to end up parsing the query string "manually," because the OOTB method will only keep one of the values. For example, RestRequest.params is a Map<String, String>, so only one value is kept. Ditto for using PageReference. Your best choice would basically be to start with a Url, then pull out the query string, then parse the remaining string.

String queryString = new Url(RestContext.request.requestURI).getQuery();
if(queryString != null) {
    String[] queryParams = queryString.split('&');
    for(String queryParam: queryParams) {
        String[] keyPair = queryParam.split('=',2);
        // Do something with keyPair[0] and keyPair[1]
    }
}
  • getting an error :"System.StringException: no protocol: /Membership" – Chitrang Shah Sep 26 '16 at 9:36

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.