You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何检查Azure DevOps工作项是否已分配故事点?API字段排查

问题描述

我正在开发一个功能,用于通知在Azure DevOps(ADO)中被分配了无故事点工作项(如用户故事、任务)的用户。已知Azure DevOps没有直接的相关设置,需要借助Power Automate(逻辑应用)或ADO REST API来实现,这个方案是可行的。

目前我编写了一段PowerShell脚本用于获取工作项字段,但输出结果中未显示故事点字段:

$Url = [string]::Format("https://dev.azure.com/{0}/{1}/_apis/wit/workitems/{2}?api-version=6.0", $Org, $Project, $WrokItemID)
Write-Output $Url

$output = Invoke-RestMethod -Uri $Url -Method Get -ContentType "application/json; charset=utf-8; api-version=6.0" -Headers $API_Header -MaximumRedirection 10 #|Format-Table -Property Title
Write-Output $output.fields

输出结果:

> $output.fields

System.AreaPath                                         : Project1
System.TeamProject                                      : Project1
System.IterationPath                                    : Project1
System.WorkItemType                                     : User Story
System.State                                            : New
System.Reason                                           : New
System.CreatedDate                                      : 2022-10-14T03:45:12.58Z
System.CreatedBy                                        : @{displayName=User1; url=https://spsprodweu1.vssps.visualstudio.com/A...2/_apis/Identities/4
                                                          3...9; _links=; id=438...ed9; uniqueName=user1@org.com; imageUrl=ht
                                                          tps://dev.azure.com/orgname/_apis/GraphProfile/MemberAvatars/aad.N...5;
                                                          descriptor=aad.N...5}
System.ChangedDate                                      : 2022-10-14T03:45:12.58Z
System.ChangedBy                                        : @{displayName=User1; url=https://spsprodweu1.vssps.visualstudio.com/Ad5..b2/_apis/Identities/4
                                                          38ce6; _links=; id=43c-0f7ca; uniqueName=user1@org.com; imageUrl=ht
                                                          tps://dev.azure.com/orgname/_apis/GraphProfile/MemberAvatars/aad....5;
                                                          descriptor=aad.N...5}
System.CommentCount                                     : 0
System.Title                                            : ADO_WI_Test
System.BoardColumn                                      : New
System.BoardColumnDone                                  : False
Microsoft.VSTS.Common.StateChangeDate                   : 2022-10-14T03:45:12.58Z
Microsoft.VSTS.Common.Priority                          : 2
Microsoft.VSTS.Common.ValueArea                         : Business
WEF_70E13435C052470DBE88ACE53A03C356_Kanban.Column      : New
WEF_70E13435C052470DBE88ACE53A03C356_Kanban.Column.Done : False
WEF_C59C4331514542BD8FF08D9FF8E61A92_Kanban.Column      : New
WEF_C59C4331514542BD8FF08D9FF8E61A92_Kanban.Column.Done : False
WEF_440176F1D1854ABE94FA40D2A944E6BE_Kanban.Column      : New
WEF_440176F1D1854ABE94FA40D2A944E6BE_Kanban.Column.Done : False
WEF_FDB767168B6C49C2BAB0BAFEAF9ED11C_Kanban.Column      : New
WEF_FDB767168B6C49C2BAB0BAFEAF9ED11C_Kanban.Column.Done : False
解决办法

1. 明确故事点字段的标准引用名

故事点对应的ADO标准字段引用名为Microsoft.VSTS.Scheduling.StoryPoints,如果工作项未设置该字段值,API默认不会返回这个字段。需要在请求中显式指定要获取的字段,或者先确认工作项是否确实未设置故事点。

2. 修改API请求,强制获取故事点字段

修改URL参数,添加$fields参数指定要返回的字段,包含故事点字段:

$Url = [string]::Format("https://dev.azure.com/{0}/{1}/_apis/wit/workitems/{2}?api-version=6.0&$fields=System.Id,System.Title,Microsoft.VSTS.Scheduling.StoryPoints,System.AssignedTo", $Org, $Project, $WrokItemID)

这样无论故事点是否有值,都会在返回结果中显示该字段。

3. 验证自定义字段配置(若有)

如果项目使用了自定义的故事点字段(而非ADO默认字段),需先确认字段的引用名:

  • 打开Azure DevOps项目设置 → 工作项 → 字段
  • 找到对应故事点字段,查看其“引用名”
  • 在API请求中替换为该引用名即可获取字段值

4. 通知功能后续实现建议

成功获取无故事点的工作项后,可按以下逻辑完成通知:

  • 从返回结果的System.AssignedTo字段提取被分配用户信息
  • 通过Power Automate发送邮件通知,或调用ADO通知API触发站内通知
  • 借助Windows任务计划或Azure自动化账户定期运行脚本,扫描未设置故事点的工作项

内容的提问来源于stack exchange,提问作者Cataster

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.16 18:45:36