I am actually using named credentials to do a callout to another salesforce instance. The following code works well in my sandbox :

HttpRequest req = new HttpRequest();

Http http = new Http();
HTTPResponse resp = http.send(req);

system.debug('## resp :' + resp);

but when deploying to production org and setting up manually the auth. provider and named credentials, I'm getting a 404 error.

My authentication provider and named credentials has been well configured. See screenshot below :

enter image description here

However when executing the code I am obtaining the following : System.HttpResponse[Status=Not Found, StatusCode=404]. As if salesforce has not been able to evaluate the named credential. Do I need other settings a part from auth. provider and named credential?

  • 1
    Is the target org on Summer 21 release (v52)
    – identigral
    Commented Jun 8, 2021 at 5:31
  • This was the exact problem. I figure out that my production is not already in version 52 that's is why it was not working. After changing to version 50, this code work. But after changing the code to this : req.setEndpoint('callout:Oneye_connection/services/data/v52.0/sobjects/Request__c/ExternalReference__c/<and externalid>'); and set the method to PATCH it is again giving me error code 404
    – vanessen
    Commented Jun 8, 2021 at 6:01

1 Answer 1


The API version in fact was causing problem. After changing to API 50, it worked


You must log in to answer this question.

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