17

Can we get all remote site settings in apex ?

I would like to check if a remote site setting exists or not.

7

You can use ToolingAPI to access the RemoteSiteSettings. This works either via Apex using this https://github.com/afawcett/apex-toolingapi or even via JavaScript using that approach http://andyinthecloud.com/2014/07/29/post-install-apex-metadata-api-configuration-solved/

Of course both options would require some serious understanding and adaption on your end.

6

The RemoteSiteSetting is not directly exposed in Apex. It is neither possible to query it, nor to instantiate it.

RemoteSiteSetting s = new RemoteSiteSetting();

results in Invalid Type

SELECT Id FROM RemoteSiteSetting

results in sObject type 'RemoteSiteSetting' is not supported.

4
  • Is there any way like from api or anything ?
    – Eric
    Oct 7 '14 at 10:09
  • You could give the apex-mdapi a try: github.com/financialforcedev/apex-mdapi Oct 7 '14 at 10:13
  • I found no luck with mdapi :(
    – Eric
    Oct 7 '14 at 10:40
  • @AlexanderJohannes - 5 years later and they never built support for this? Would some alternative way instead of trying to do this through anonymous execution involve the DX CLI and probably puppeteer?
    – trebleCode
    Jul 24 '19 at 20:32
0

If you use Salesforce Inspector (Chrome Extension) https://chrome.google.com/webstore/detail/salesforce-inspector/aodjmnfhjibkcdimpodiifdjnnncaafh?hl=en or other tool that allows you to query using the Tooling API, you can just query:

select id, SiteName, EndpointUrl from RemoteProxy

If using Salesforce inspector, make sure "Use Tooling API?" checkbox is checked.

-1

There is a way to do it but it's messy and involves parsing and screen grabbing. The Metadata API could give me the remote site settings and create one but not provide me with the actual URLs. I was able to get all the Remote site IDs and do a call out to retrieve the data I wanted.

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.