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
kvm1231kvm1231 

What is the difference between Named credentials and Remote site settings in Salesforce?

Hi,
Can you please let me know what actual difference between Named Credentials and Remote site settings in Salesforce and please let me know which case we will prefer Named credentials and Remote site settings.

Thanks,
KVM
 
DeepthiDeepthi (Salesforce Developers) 
Hi Kvm,

When you want to access the external sites in your Salesforce application using callouts, webservices, etc... You need to add that in the Remote Site Settings. This is just a security that force.com platfom is going to check. Before any Visualforce page, Apex callout, or JavaScript code using XmlHttpRequest in an s-control or custom button can call an external site, that site must be registered in the Remote Site Settings page, or the call will fail. 

A named credential specifies the URL of a callout endpoint and its required authentication parameters in one definition. To simplify the setup of authenticated callouts, specify a named credential as the callout endpoint. If you instead specify a URL as the callout endpoint, you must register that URL in your org’s remote site settings and handle the authentication yourself. For example, for an Apex callout, your code would need to handle authentication, which can be less secure and especially complicated for OAuth implementations.

Refer the below link for more information: https://help.salesforce.com/articleView?id=named_credentials_about.htm&type=0

Hope this helps you!
Thanks,
Deepthi