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();

     // 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 ' +
     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);

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)

  • 2
    Have you inadvertently created your own class called HttpRequest? Try just doing an anonymous HttpRequest req = new HttpRequest();System.debug(req); Commented Jan 5, 2017 at 21:18
  • Ha, I might have by accident - FAIL
    – glls
    Commented Jan 5, 2017 at 21:22
  • Yup, found an empty http request class in my devorg from months ago
    – glls
    Commented Jan 5, 2017 at 21:23
  • It happens :) You might be able to work around it by prefixing with the namespace, but it would be safer to just get rid of the conflicting class. Commented Jan 5, 2017 at 21:25

1 Answer 1


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.

  • 2
    deleted it as soon as I found it, some empty class hanging there that was probably created by mistake months ago
    – glls
    Commented Jan 5, 2017 at 21:24
  • 1
    That Past Self person has a lot to answer for. Mine is always screwing me up. Commented Jan 5, 2017 at 21:26

You must log in to answer this question.

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