I am using the Azure DevOps Odata endpoints to retrieve data from my projects.
Now I face the problem that I am not able to group by the result based on a sub property of a workitem. The following ODATA query returns me an error message:
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"
}
}
When I try to do the same with a normal property, everything works fine:
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))
You can use the below query 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
And then you will get the result as below.
{
"@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}"
}
}
]
}
Hope this help.