Fixing Sitecore 9 Commerce Invalid URI Error

June 5, 2019

An invalid uri error was often logged in a Sitecore 9.0.1 Commerce solution. The exception looked like:

            ERROR SitecoreConnectionManager.Error: Message=Invalid URI: The hostname could not be parsed.
        

I found these articles suggesting that the content policy was not setup correctly:

We have one content policy json file in our solution in the following location:

            /wwwroot/data/Environments/PlugIn.Content.PolicySet-1.0.0.json
        

In our case the parameter, Host, was mapped to a default hostname, sxa.storefront.com. We don't use that domain in our configuration and it's not mapped to a valid certificate. Changing Host to a valid hostname fixed the issue.