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
Mickey Stringer 5Mickey Stringer 5 

REST GET with Multiple Parameters

I've seen many variations of this question, but none seem to provide the answer. I want to pass multiple parameters (different parameters, not different values of the same parameter) to the GET method of a RestResource class. I want to then retrieve each parameter and send them to the appropriate method for processing (each param goes to a different method, then the aggregate result is returned to the client). I'm currently going about this like so:
param1Var = RestContext.request.params.get('param1'); 
param2Var = RestContext.request.params.get('param2'); 
param3Var = RestContext.request.params.get('param3');

The issue I'm having is that only the first parameter is being grabbed.
My URL looks like this - apexrest/apiClass?param1=X&param2=Y&param3=Z
For every parameter after the first one I receive the error, "'param' is not recognized as an internal or external command, operable program or batch file." The variables set to the parameter values also remain null.
How can I accomplish this? I would like to pass all parameters very simply in the URL
Best Answer chosen by Mickey Stringer 5
Mickey Stringer 5Mickey Stringer 5
Yea, that's how I was doing it. The issue was I was validating with cURL. When passing multiple parameters in a GET with cURL, you apparently need to put the URL in quotes (double quotes in my case).

All Answers

Mickey Stringer 5Mickey Stringer 5
I should add that the value passed for param1 in the URL is appropriately assigned to param1var
Raj VakatiRaj Vakati
You need to pass the params as below  apexrest/apiClass/param1=X&param2=Y&param3=Z
 
Mickey Stringer 5Mickey Stringer 5
Yea, that's how I was doing it. The issue was I was validating with cURL. When passing multiple parameters in a GET with cURL, you apparently need to put the URL in quotes (double quotes in my case).
This was selected as the best answer