如何在 Rest API 中按变量名过滤 GroupVariables

How filter GroupVariables by variable name in the Rest API

基于 documentation 我可以使用以下请求获得特定的变量组

GET .../_apis/distributedtask/variablegroups?groupName={groupName}

此 returns 特定变量组的所有变量。

我想获取特定变量的详细信息,这样我就不必下载所有变量。 例如

GET .../_apis/distributedtask/variablegroups?groupName={groupName}&VariableName={MyName}

我已经搜索过了,但我没有找到任何东西。

我认为不可能只得到一个变量,所有的想法都是它是一个组,目前 Rest API 让你得到这个组。

但是,如果您使用 PowerShell,则可以在执行 Rest 时轻松过滤结果:

$url = "https://dev.azure.com/{organization}/{project}/_apis/distributedtask/variablegroups?groupName={name}&api-version=5.0"
$varName = "MyName"
$varValue = (Invoke-RestMethod -Uri $url -Method Get -ContentType application/json).value.variables.$varName