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
SFMiesterSFMiester 

Error: Invalid interface: HttpCalloutMock

Hi Experts!

Im trying to complete one of the trailhead tasks, but it keeps erroring out with the following error message. AnimalsHttpCalloutMock: Invalid interface: HttpCalloutMock​. Am I doing something wrong?
@isTest
global class AnimalsHttpCalloutMock implements HttpCalloutMock {
    // Implement this interface method
    global HTTPResponse respond(HTTPRequest request) {
        // Create a fake response
        HttpResponse response = new HttpResponse();
        response.setHeader('Content-Type', 'application/json');
        response.setBody('{"animals": ["majestic badger", "fluffy bunny", "scary bear", "chicken", "mighty moose"]}');
        response.setStatusCode(200);
        return response; 
    }
}
Appreciate the help!
 
Best Answer chosen by SFMiester
charforcecharforce
It sounds like you have an Apex class with class name "HttpCalloutMock" already created somewhere in your orgs Apex classes. Find this Apex class in your org and either delete it or rename it. That should solve your issue. 

All Answers

charforcecharforce
It sounds like you have an Apex class with class name "HttpCalloutMock" already created somewhere in your orgs Apex classes. Find this Apex class in your org and either delete it or rename it. That should solve your issue. 
This was selected as the best answer
SFMiesterSFMiester
Hi charforce! you were right! Thank you very much!