Azure DevOps Odata Group by child 属性 不工作

Azure DevOps Odata Group by child property is not working

我正在使用 Azure DevOps Odata 端点从我的项目中检索数据。

现在我面临无法根据工作项的子 属性 按结果分组的问题。 以下 ODATA 查询 returns 给我一个错误信息:

https://analytics.dev.azure.com/<organisation>/<project>/_odata/v2.0/WorkItems?
$filter=WorkItemType eq 'Activity'&
$select=AssignedTo/UserName,TotalCount&
$apply=groupby((AssignedTo/UserName, WorkItemType),aggregate($count as TotalCount))&
$expand=AssignedTo($select=UserName)

VS403483: The query specified in the URI is not valid: VS403522: The property 'AssignedTo' is not available on the specified Project(s). Please remove 'AssignedTo' from your query and try again..","innererror":{"message":"VS403522: The property 'AssignedTo' is not available on the specified Project(s). Please remove 'AssignedTo' from your query and try again.

{
    "State": "Closed",
    "AssignedTo": {
        "UserName": "User 2"
    }
},
{
    "State": "New",
    "AssignedTo": {
        "UserName": "User 1"
    }
}

当我尝试对普通 属性 执行相同操作时,一切正常:

https://analytics.dev.azure.com/<organisation>/<project>/_odata/v2.0/WorkItems?
$filter=WorkItemType eq 'Activity'&
$select=State,TotalCount&
$apply=groupby((State, WorkItemType),aggregate($count as TotalCount))

您可以使用以下查询 url。

https://analytics.dev.azure.com/{orgname}/{projectname}/_odata/v2.0/WorkItems?
$apply=filter(WorkItemType eq 'Bug')/groupby((AssignedTo/UserName, WorkItemType),aggregate($count as TotalCount))
&select=AssignedTo/UserName,TotalCount

然后你会得到如下结果。

{
    "@odata.context": "https://analytics.dev.azure.com/{orgname}/{projectname}/_odata/v2.0/$metadata#WorkItems(AssignedTo(UserName),WorkItemType,TotalCount)",
    "value": [
        {
            "@odata.id": null,
            "WorkItemType": "Bug",
            "TotalCount": 3,
            "AssignedTo": {
                "@odata.id": null,
                "UserName": "{username1}"
            }
        },
        {
            "@odata.id": null,
            "WorkItemType": "Bug",
            "TotalCount": 4,
            "AssignedTo": {
                "@odata.id": null,
                "UserName": "{username2}"
            }
        }
    ]
}

希望对您有所帮助。