In my project, I have three environments and I want to toggle a feature flag only on for a specific environment Is it possible to toggle unleash feature flag with API for a development environment only? I am using the below code to toggle the flag but it works for default mode only
function enabledToggle() {
axios
.get("http://unleash.host.com/api/admin/features/:featureName/toggle/on", {
headers: {
Authorization: ${"my-token"},
}
})
.then(function (response) {
console.log(response.data);
})
.catch(function (error) {
console.log(error);
});
}
I also tried one more way but I got this error I am trying to turn on the feature flag through this API but I am getting an error when I execute the above function I am getting this error Request failed with status code 415 can anyone help what I am doing wrong? here is my code
function oNFeatureFlag(){
axios({url:"https://host.name/api/admin/projects/default/features/feature-name/environments/development/on",
headers: {Authorization: ${"my token"},},
method: "post",
})
.then(function (response) {
console.log(response);
})
.catch(function (error) {
console.log(error);
});}
Try setting content-type to application/json explicitly.
This is most likely because of the way Axios sets the content-type header. From what I understand, it sets content-type to application/json;charset=utf-8. Prior to a recent version of Unleash, Unleash didn't parse this properly, so it would give you a 415 Unsupported Media Type response.
For reference, here's the same question as a GitHub issue.