1

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();
req.setEndpoint('callout:Oneye_connection/services/data/v52.0/query/?q=SELECT+name+from+account+limit+1');
req.setMethod('GET');
req.setHeader('Content-Type','application/json'); 

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?

2
  • 1
    Is the target org on Summer 21 release (v52)
    – identigral
    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
    Jun 8, 2021 at 6:01

1 Answer 1

0

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

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.