title: Invalid type for Http* method: system.RestRequest in apex
body: <p>Hi i am trying to create an apex rest service but getting error
  Invalid type for Http* method: system.RestRequest</p>
  
  <p>here is the function where i am getting this error .</p>
  
  <pre><code>  @RestResource(urlMapping='/v.9/scorecard/*') 
  global with sharing class ScorecardRestSvc {
  
    /**
    * @date July 26, 2011
    * @description Update a question answer. 
    * @return Map&lt;String,String&gt; - results and boolean success message
    */
  
    @HttpPost
    global Static Map&lt;String,String&gt; doPut(RestRequest req, RestResponse res) {
  
      String answerId = req.requestURI.substring(req.requestURI.lastIndexOf('/')+1);
      string updateResult = 'Waiting to run';
      Map&lt;String,String&gt; returnMap = new Map&lt;String,String&gt;();
      returnMap.put('Success','True');
  
      // mark the participant as having no submission
        if(req.params.containsKey('deleteSubmission') &amp;&amp; req.params.get('deleteSubmission').toLowerCase() == 'true') {
        markParticipantAsNoSubmission(req,res);
          returnMap.put('Message','Participant marked as no submission.');
          return returnMap;    
        } 
  
      try {
  
        if(!isValidId(answerId) || answerId.length() == 0) {
          returnMap.put('Method','Bulk');
          updateResult = updateObjectsFromXml(req,res);     
        } else {
          returnMap.put('Method','Single');
          updateResult = updateSingleAnswer(req,res);
        }
  
        returnMap.put('Update Result', updateResult);
  
        if(updateResult != 'All records updated successfully. ' &amp;&amp; updateResult != 'All records updated successfully. Survey set to scored. No further changes allowed') {
          returnMap.put('Success','False');
        }     
      } catch(Exception e) {
        returnMap.put('Error',e.getMessage());
      } 
  
      return returnMap;   
    }
  
    private static void markParticipantAsNoSubmission(RestRequest req, RestResponse res) { 
      ID participantId = (ID)req.params.get('participantId');
      // get the participant and mark them as no submission
      Challenge_Participant__c cp = [select id, Has_Submission__c from Challenge_Participant__c 
        where id = :participantId];
      cp.Has_Submission__c = false;
      cp.Status__c = 'Submission Rejected';
      update cp;      
    }
  
    private static String updateObjectsFromXml(RestRequest req, RestResponse res) {
  
      string returnMessage = 'All records updated successfully. ';
  
      try {
        String xml = req.requestBody.toString().trim();
        System.debug('===================== here is the xml passed: ' + xml);
        List&lt;sObject&gt; updateList = parseUpdateXML(xml);
  
        //before we update we need to make sure this card is not scored
        List&lt;QwikScore_Question_Answer__c&gt; thisAns = [select QwikScore_Scorecard__r.Scored__c, QwikScore_Scorecard__c 
          from QwikScore_Question_Answer__c where id = :updateList[0].Id];
  
        if(thisAns[0].QwikScore_Scorecard__r.Scored__c) throw new customException('This scorecard has been marked as scored. No further updates are available.');
  
       // ScoringEngine.saveAnswers(thisAns[0].QwikScore_Scorecard__c, updateList);           
  
        if(req.params.containsKey('setScored') &amp;&amp; req.params.get('setScored').toLowerCase() == 'true') {
        //  ScoringEngine.gradeScorecard(thisAns[0].QwikScore_Scorecard__c);
          returnMessage += 'Survey set to scored. No further changes allowed';        
        }
  
      } catch(Exception e) {
        returnMessage = e.getMessage();
      }
  
      return returnMessage;
    }
  
    private static String updateSingleAnswer(RestRequest req, RestResponse res) {
  
      String answerId = req.requestURI.substring(req.requestURI.lastIndexOf('/')+1);
  
      // get a map of all field in the member__c custom object
      Map&lt;String, Schema.SObjectField&gt; sObjectFieldsMap = Schema.SObjectType.QwikScore_Question_Answer__c.fields.getMap();
      // don't let them update the following fields -- use all lowercase for comparison
      Set&lt;String&gt; noUpdateFields = new Set&lt;String&gt;{'Answer_Value__c,QwikScore_Scorecard__c,Weighted_Score__c,Answer_Value__c,IsAnswered__c'};
  
      String returnMessage = 'All records updated successfully. ';
  
      try {
  
        QwikScore_Question_Answer__c qa = new QwikScore_Question_Answer__c(Id=id.ValueOf(answerId));
  
        for (String key : req.params.keySet()) {
          // only add params if they are valid field on the object and not on the no-update list
          if (sObjectFieldsMap.containsKey(key) &amp;&amp; !noUpdateFields.contains(key.toLowerCase()))
            qa.put(key,req.params.get(key)); 
        }
  
        List&lt;QwikScore_Question_Answer__c&gt; thisAns = [select QwikScore_Scorecard__r.Scored__c,
          QwikScore_Scorecard__c from QwikScore_Question_Answer__c where id = :qa.Id];
  
        if(thisAns.isEmpty()) throw new customException('Could not locate answer with Id' + qa.Id);
  
        if(thisAns[0].QwikScore_Scorecard__r.Scored__c) throw new customException('This scorecard has been marked as scored. No further updates are available.');
  
        //ScoringEngine.saveAnswers(thisAns[0].QwikScore_Scorecard__c, new List&lt;QwikScore_Question_Answer__c&gt;{qa});
  
        if(req.params.containsKey('setScored') &amp;&amp; req.params.get('setScored').toLowerCase() == 'true') {
          //ScoringEngine.gradeScorecard(thisAns[0].QwikScore_Scorecard__c);
          returnMessage += 'Scorecard set to scored. No further changes allowed';          
        }
  
      } catch(Exception e) {
        returnMessage = e.getMessage();
      }
  
      return returnMessage;     
    }
  
    /*******************************************
    Used to create a list of sObjects ready for updating from 
    XML data that would likely be passed in a request
  
    This method is pretty cool actually. You can pass it some XML
    formated in the way outlined previously and it will get you a list
    of objects ready for update. I think they all have to be of the same type
    though.
    *******************************************/
    private static List&lt;sObject&gt; parseUpdateXML(String Xml) {
  
      Map&lt;Id,sObject&gt; updates = new Map&lt;Id,sObject&gt;();  
      xml = xml.trim();
      Xmlstreamreader reader = new Xmlstreamreader(xml);
      Id lastId;
      string fieldName;
      Map&lt;String, Schema.SObjectType&gt; gd = Schema.getGlobalDescribe();
      Schema.SobjectType oType;
  
      while (reader.hasNext()) {
  
        if (reader.getEventType() == XmlTag.START_ELEMENT &amp;&amp; reader.getLocalName().toLowerCase() == 'object') {
  
          if(oType == null) oType = gd.get(reader.getAttributeValueAt(0));
  
          sObject thisObject;
          if(reader.getAttributeLocalName(1) == 'id') thisObject= oType.newSObject(reader.getAttributeValueAt(1));
  
          if(thisObject != null) {
            updates.put(thisObject.id,thisObject);
            lastId = thisObject.id;
          }
        } else if(reader.getEventType() == XmlTag.START_ELEMENT &amp;&amp; reader.getLocalName().toLowerCase() == 'field') {
          fieldName = reader.getAttributeValueAt(0);
          sObject thisObject = updates.get(lastId);
          reader.next();
          thisObject.put(fieldName,getDecodedString(reader));
          updates.put(thisObject.id,thisObject);  
        }
      reader.next();
      }
  
      return updates.values();
  
    }
  
    /*******************************************
    Test to see if a given string is a valid id
    ********************************************/
    public static Boolean isValidId(String s) {
      Id validId;
      try {
        validId = s;
        return true; 
      } catch (Exception ex) {
        return false;
      }
    } 
  
    public class customException extends Exception {}
  
    public static String getDecodedString(Xmlstreamreader reader) {
      return EncodingUtil.urlDecode(reader.getText(), 'UTF-8').trim();
    }
  
  }
  </code></pre>
  
  <p>can any one please tell why i am getting this error and how to rectify it?</p>