I have created a class for api request. I am also sending a parameter in url while requesting for HttpGet. How can I get the value from the url in a HttpGet method. When I added the RestRequest req, RestResponse res as parameter to my apex method I am getting an error

Error: Compile Error: Invalid type: HTTP GET/DELETE methods do not support parameters at line 4 column 26

Can anyone help me out on this issue. This is my apex class.

global class mycallclass{
  global static String getmycall(RestRequest req, RestResponse res) {
    String name = RestRequest.params.get('name');
    return 'WooW Success';

2 Answers 2


You can access the params map via static fields like this:

Map<String, String> params = RestContext.request.params;
String name = params.get('name');

(Remove the getmycall method parameters you presently have in your code.)


You can send the parameter through the URL, and get it by using RestContext.request like this:

global class mycallclass {
    global static String getmycall() {
        RestRequest req = RestContext.request;
        // Get name from url (represented by the * sign)
        String name = req.requestURI.substring(req.requestURI.lastIndexOf('/')+1);

        // Do Stuff here...

        return 'WooW Success ' + name;
  • 1
    Note there is a String.substringAfterLast (instance) method.
    – Adrian Larson
    Jul 7, 2016 at 21:46

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .