I just discovered that we cannot access from Salesforce any URL which contains an underscore (_). When you try to enter a URL with an underscore in remote site settings, you get the error below. I assumed there would be a simple solution to this, but after searching I've found nothing at all. Is there something obvious I missing?
Is it impossible in Salesforce to authorize a URL endpoint (in remote site settings) that contains an underscore?
Yes you cannot! You can map the url to some other as a workaround!– Mohith ShrivastavaJun 8, 2020 at 2:51
RFC 2872 allows underscores for subdomains, as written in your example, but not all services support this nomenclature. Unfortunately, at this time, you'll need to choose a hostname and subdomain that does not include underscores. In particular, you also won't be able to reference sandboxes that include an underscore in its name, so you should avoid naming sandboxes this way.
Thanks, the funny thing I discovered is that this is easy to work around by using a named credential, there is no problem using an underscore there. You would think if Salesforce allows it in named credentials, it would allow it in remote site settings.
1I don't think it does, throws an error later in the flow: FATAL_ERROR System.CalloutException: Invalid characters in hostname Don't seem to be able to encode it either.– NonickJun 10, 2022 at 8:17