Sometimes you spot interesting things online that you have to figure out ๐. This time it was a tweet from Martin Ehrnst:
@AzureDevOps i'm using your API to create new projects. However, I would like to provision these without services like boards. I cannot find any way to to do this. Doesn't the API support this?
— Martin Ehrnst โ๏ธ (@ehrnst) May 21, 2021
In Azure DevOps you can enable or disable features on a per-project basis:
After some reverse engineering I found out that you can request and set the state of these features by calling into the API.
POST: https://dev.azure.com/{ORGANIZATION}/_apis/FeatureManagement/FeatureStatesQuery/host/project/{PROJECTID}?api-version=4.1-preview.1
Indicating in the body what you want to know. If you only pass in 1 featureId, you only get the state for that single feature.
{
"featureIds": [
"ms.vss-work.agile",
"ms.vss-code.version-control",
"ms.vss-build.pipelines",
"ms.vss-test-web.test",
"ms.feed.feed"
],
"featureStates": {},
"scopeValues": {
"project": "{PROJECTID}"
}
}
You can set the state of a feature by sending in a PATCH request for a single feature. Posting for multiple features in one go doesnโt seem to work. This makes sense since the API also does it on a per feature basis.
PATCH: https://dev.azure.com/{ORGANIZATON}/_apis/FeatureManagement/FeatureStates/host/project/{PROJECTID}/{featureId}?api-version=4.1-preview.1
With body:
{
"featureId": "ms.feed.feed",
"scope": {
"userScoped": false,
"settingScope": "project"
},
"state": 1
}
Where featureId from the body needs to match the featureId in the URL (find the list in the example above).
To bad you cannot pass in these settings through the API when you create a project. At least there is another way to get things working ๐.