1

When installing a package using the links it asks the user to confirm the addition of remote site settings.

When installing a package via the Metadata API using createMetadata() or the packaging API the remote site settings do not get activated and there is no prompt for the user to approve.

Does anyone know of a way to get the remote site settings to be activated during a package install via the API?

I assume there is not but interested to hear if there are any good ideas out there. I do not need code or anything but if there is a setting or field in the XML that can be passed it would be nice to know.

My current approach will be to develop a UI after the installation is complete for them to activate any inactive remote site settings within the namespace

UPDATE: Based on below answer

I tried using postman and my code and get HTTP error code 500 with the following:

endpoint

https://[redacted]-dev-ed.cs8.my.salesforce.com/services/Soap/m/43.0/ORGID

payload

<?xml version="1.0" encoding="UTF-8"?>
    <env:Envelope xmlns:env="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
        <env:Header>
            <urn:SessionHeader xmlns:urn="http://soap.sforce.com/2006/04/metadata">
                <urn:sessionId>redacted</urn:sessionId>
            </urn:SessionHeader>
        </env:Header>
        <env:Body>
            <createMetadata xmlns="http://soap.sforce.com/2006/04/metadata">
                <metadata xsi:type="InstalledPackage">
                    <activateRss>true</activateRss>
                    <versionNumber>version</versionNumber>
                    <fullName>namespace</fullName>
                </metadata>
            </createMetadata>
        </env:Body>
    </env:Envelope>

and I receive the following response. I tried putting the tag in all positions without but the results were the same

<?xml version="1.0" encoding="UTF-8"?>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
    <soapenv:Body>
        <soapenv:Fault>
            <faultcode>soapenv:Client</faultcode>
            <faultstring>Element {http://soap.sforce.com/2006/04/metadata}activateRss invalid at this location in type InstalledPackage</faultstring>
        </soapenv:Fault>
    </soapenv:Body>
</soapenv:Envelope>

Must be a field returned by readMetadata and not available on createMetadata??

  • Named Credentials also get round this issue - if there is a named credential for the URL, it effectively authorizes the endpoint, and they don't need activating – BritishBoyinDC May 8 at 14:26
  • @BritishBoyinDC named credentials in my use case would not be desireable as there is no ui that could be built around it and we would need 40 or so of them. Customers would not be happy lol. We got around it by automating the activation of the remote site via apex thanks to the org API’s being opened up to not need a remote site – Eric May 8 at 16:06
0

According to the MDAPI documentation for InstalledPackage, there is a setting activateRss you can use as of API v43: https://developer.salesforce.com/docs/atlas.en-us.api_meta.meta/api_meta/meta_installedpackage.htm

  • Thank you and I thought you nailed it, unfortunately it results in a 500 error. It works fine without it......Any thoughts? See updated question – Eric Jul 20 '18 at 1:15
  • Strange. No idea. Does it work if you use deploy rather than createMetadata? – Charles T Jul 20 '18 at 3:50
  • I would not expect it to. I can't use deploy anyway as I am doing this from apex....Gotta stick with HttpRequest and XML payload. Of course the whole metadata API thing from Apex confuses me and I hacked together the XML from examples and the SF documentation on object metadata so........ – Eric Jul 20 '18 at 3:52

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.