2

I've been experimenting with a build script to generate a scratch org based on a Devhub that uses external API calls.

Ideally this script would

  1. Build the scratch org and add Remote Site Settings for APIs
  2. Push Code to the scratch org
  3. Call APIs in testing, etc...

Based on my research, this may not be a feature available; but I was curious if anyone knew a workaround.

Here's a basic project-scratch-def.json:

{
  "orgName": "Scratch Org",
  "language": "en_US",
  "sourceOrg": "00DXXXXXXXXXXXXX",
  "features": ["EnableSetPasswordInApi"],
  "settings": {
    "lightningExperienceSettings": {
      "enableS1DesktopEnabled": true
    },
    "mobileSettings": {
      "enableS1EncryptedStoragePref2": false
    },
    "securitySettings": {
      "passwordPolicies": {
        "minimumPasswordLifetime": false
      }
    },
    "remoteSiteSetting": {
      "fullName": "APINAME",
      "url": "https...",
      "isActive": true
    }
  }
}

I've tried placing remoteSiteSetting[s] in multiple places just to see if I get a hit.

It is listed in the Metadata here.

Anyone have any thoughts?

4

You can include it as part of your source tree (force-app/main/default/remoteSiteSettings/). Create the folder, and place the file called myRemoteSiteName.remoteSite-meta.xml (replace myRemoteSiteName with the name of the remote site), and in that file, include the XML located in the documentation, replacing the properties as you need to. Alternatively, create a Remote Site in an org, and use sfdx force:source:retrieve or sfdx force:source:pull to get a file you can use. You can push/deploy that file to any other org.

3
  • Def way to go - this is how we use. For orgs where we test our installed package we also have a step after package installation: sfdx force:source:deploy -p unpackaged/remoteSiteSettings
    – dzh
    Jul 28 at 1:18
  • The master himself. That will work like a charm. For anyone else looking at this, the full file name would be myRemoteSiteName.remoteSite-meta.xml
    – seflo
    Jul 28 at 1:32
  • @seflo You're right. A minor oversight. I've edited that in now.
    – sfdcfox
    Jul 28 at 1:39

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.