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
Daksh BansalDaksh Bansal 

Update Remote Site Setting using apex

Need urgent help, we have a requirement where we need to update remote site setting using apex. I have tried to search solution if this can possiable via tooling/metadata api but no luck. If anyone worked same kind of requirement please help.
NagendraNagendra (Salesforce Developers) 
Hi Bansal,

I don't believe there is a way to do what you're asking (I couldn't find one). To allow creating Remote Site Settings using Apex would create a lot of security problems; that is probably why it's not allowed.

However, I was able to find a question https://stackoverflow.com/questions/6832695/reference-a-remote-site-setting-url-in-apex-class and answer https://stackoverflow.com/questions/6832695/reference-a-remote-site-setting-url-in-apex-class/6836769#6836769 with some recommendations that relate to this question.

"The best way I've found to save configuration values is to use Apex Custom Settings http://www.salesforce.com/us/developer/docs/apexcode/index_Left.htm#StartTopic=Content/apex_methods_system_custom_settings.htm#kanchor672. To set the Remote Site settings programmatically you could use the Metadata APIhttps://developer.salesforce.com/docs/atlas.en-us.api_meta.meta/api_meta/#StartTopic=Content/meta_remotesitesetting.htm#kanchor148."

Regards,
Nagendra