[SalesForce] Error: Compile Error: Method does not exist or incorrect signature: [httprequest] methods

Trying to create an Apex Class or Do a callout in Open execute anonymous window from my Dev Org, all the HTTP Request Methods are returning Error: Compile Error: Method does not exist or incorrect signature: [httprequest].setXXX(String)

For Ex:

public class AuthCallout {

   public void basicAuthCallout(){
     HttpRequest req = new HttpRequest();
     req.setEndpoint('http://www.yahoo.com');
     req.setMethod('GET');

     // Specify the required user name and password to access the endpoint
     // As well as the header and header information

     String username = 'myname';
     String password = 'mypwd';

     Blob headerValue = Blob.valueOf(username + ':' + password);
     String authorizationHeader = 'BASIC ' +
     EncodingUtil.base64Encode(headerValue);
     req.setHeader('Authorization', authorizationHeader);

     // Create a new http object to send the request object
     // A response object is generated as a result of the request  

     Http http = new Http();
     HTTPResponse res = http.send(req);
     System.debug(res.getBody());
   }
}

from https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_classes_restful_http_httprequest.htm fails to save as an apex class with the Error message:

Error: Compile Error: Method does not exist or incorrect signature:
[httprequest].setEndpoint(String)

Best Answer

This sort of error usually occurs if you create an Apex class with the same name as the System class.

Look for an Apex class called HttpRequest and either delete it or rename it.