Today, I stumbled upon an intriguing post by Nicky Vadera regarding environment-specific settings in Content Hub. In this blog post, I'll provide you with the key takeaways, and you can read the original post here.
By default, Content Hub allows you to create settings that are not tied to any specific environment through the user interface. If you wish to create environment-specific settings, you'll need to resort to the REST API – a slightly inconvenient method in my opinion. Hopefully, Sitecore will incorporate this feature into their user interface soon.
The most significant distinction between a standard setting and an environment-specific setting lies in their inclusion during package exports. Normal settings get included, while environment-specific settings do not. This separation ensures a safe and reliable method for transferring settings between different environments.
Now, let's discuss how to create an environment-specific setting:
Since you can't create environment-specific settings using the user interface, you'll have to utilize the management REST API. It's important to note that this is different from the GraphQL API, which is designed for high-scale queries. To make this work, you'll need to send an HTTP POST request to your Content Hub instance at https://[yourinstance]/api/entities.
In the POST method, use the following body:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 | { "identifier": "", "entitydefinition": { "href": "{{host}}/api/entitydefinitions/M.Setting" }, "relations": { "SettingCategoryToSettings": { "parent": { "href": "{{host}}/api/entities/{{SettingCategoryId}}" } } }, "properties": { "M.Setting.Name": "{{SettingName}}", "M.Setting.Label": { "en-US": "{{SettingLabel}}" }, "M.Setting.Value": {}, "M.Setting.EnvironmentSpecific": true } } |
To customize the settings, you should replace the values within the double brackets {{...}} with your own preferences. However, to create a setting, you must first establish a Settings Category, and you can easily do this through the user interface.
The critical element in the request body is the 'M.Setting.EnvironmentSpecific,' and it's imperative that you set this to 'true'.
In the upcoming month, I will try to build this feature in my Content Hub Power Extension.
Stay tuned!