+ Start a Discussion
Robert Baillie 5Robert Baillie 5 

Cannot create and configure Remote Site Settings via the Tooling API

As part of an automated sandbox refresh and re-configure process we would like to be able to set up Remote Site Settings via the API.

This appears to be published as the RemoteProxy object.

The theory is that our script will disable the existing settings, and create replacements fully configured.  It appears that we need to do this as we cannot update the existing settings.

Unfortunately it doesn't look like we can set everything up.

If we pass through everything we want to set on a create message we get:
FIELD_INTEGRITY_EXCEPTION: Only the Metadata and FullName fields may be specified on RemoteProxy, or else Metadata must be excluded. Invalid field(s): [ProtocolMismatch, SiteName, IsActive, EndpointUrl]]
  fields: [ 'ProtocolMismatch', 'SiteName', 'IsActive', 'EndpointUrl' ]
If we omit the Metadata field (as the message implies we should we get:
Adding Remote Site Setting: AWS
{ [REQUIRED_FIELD_MISSING: You must provide a valid Metadata field for RemoteProxy]
  fields: [] }
Does anyone know how we might set-up the Remote Site Settings via the API?

Harsh GosarHarsh Gosar
It depands on how you have serialized JSON for e.g:

Sample code snippet:
String json ='{"FullName":"test","Metadata":{"disableProtocolSecurity":false,"isActive":true,"url":"https://test.test.test","urls":null,"description":"test"}}'; 
String endpoint = URL.getSalesforceBaseUrl().toExternalForm()+'/services/data/v41.0/tooling/sobjects/RemoteProxy/';
string method  = 'POST';

HttpRequest request = new HttpRequest();
request.setHeader('Authorization', 'Bearer ' + UserInfo.getSessionID());
request.setHeader('Content-Type', 'application/json');

Http http = new Http();
HttpResponse response = http.send(request);
System.Debug('**** Remote Site Response: ' + response.getBody()); 
sashi pandey 15sashi pandey 15
Hi Harsh,
How can i make the "url" parameter inside the json string as dynamic?
i need "URL.getSalesforceBaseUrl().toExternalForm() " to be the value of url parameter based on respective org.

I was looking to manage remote site settings through Apex and this post is really helpful. To make more helpful/reusable for people, I have created a util class on Playground at Manage Remote Site Settings through Apex (https://www.playg.app/play/remote-site-settings-with-tooling-api) which an online store for all utilities. Hope this helps


Playground is a Salesforce online community to share solutions free of cost that can be used by anyone & with one-click deploy technology, it gives hassle-free experience to test these solutions quickly. Check this out at https://playg.app to see existing/upload your solutions