Excel Powershell中链接工作项的VSTS Rest API查询

Excel Powershell中链接工作项的VSTS Rest API查询,excel,powershell,azure-devops,Excel,Powershell,Azure Devops,在PowerShell中使用VSTS的REST API,我想在我的VSTS团队项目上创建一个报告,其中包含工作项的详细信息,链接特定迭代路径和区域路径下所有工作项的关系 例:史诗→特征→用户故事。因为Epics和Features之间以及Features和UserStories之间存在父/子关系 因此,输入将是迭代路径和区域路径,相应的输出将是report.csv或.xls,其中包含这些工作项及其关系的所有详细信息 有人能告诉我如何在PowerShell中使用RESTAPI实现这一点吗 我编写了在

在PowerShell中使用VSTS的REST API,我想在我的VSTS团队项目上创建一个报告,其中包含工作项的详细信息,链接特定迭代路径和区域路径下所有工作项的关系

例:史诗→特征→用户故事。因为Epics和Features之间以及Features和UserStories之间存在父/子关系

因此,输入将是迭代路径和区域路径,相应的输出将是report.csv或.xls,其中包含这些工作项及其关系的所有详细信息

有人能告诉我如何在PowerShell中使用RESTAPI实现这一点吗

我编写了在团队项目中获取分层工作项的代码,但需要修改以根据给定的迭代和区域路径过滤列表。 同样在执行下面的代码时,querydue中的字符串比较返回power shell中的错误

错误:Invoke RestMethod:{count:1,值:{Message:解析值后遇到意外字符:G。 路径“查询”,第1行,位置163。\r\n}

$vstsAccount = "xxxx"
$projectName = "xxxx"
$user = "xxxx"
$token = "xxxx"

# Base64-encodes the Personal Access Token (PAT) appropriately
$base64AuthInfo = [Convert]::ToBase64String([Text.Encoding]::ASCII.GetBytes(("{0}:{1}" -f $user,$token)))

# Construct the REST URL to obtain Build ID
$uri = "https://$($vstsAccount).visualstudio.com/$($projectName)/_apis/wit/wiql?api-version=1.0"

$body = "{'query': 'Select [System.Id], [System.WorkItemType], [System.Title], [System.AssignedTo], [System.State] From WorkItemLinks WHERE 
((Source.[System.TeamProject] = '$projectName' and Source.[System.State] <> 'Removed') and (Source.[System.WorkItemType] = 'Epic') and
([System.Links.LinkType] = 'System.LinkTypes.Hierarchy-Forward') and (Target.[System.WorkItemType] = 'UserStory') mode(Recursive)'}"

# Invoke the REST call and capture the results (notice this uses the POST method)
$result = Invoke-RestMethod -Uri $uri -Method Post -ContentType "application/json" -Headers @{Authorization=("Basic {0}" -f $base64AuthInfo)} -Body $body

修改部分代码,如下所示:

$query = "Select
    [System.Id],
    [System.WorkItemType],
    [System.Title],
    [System.AssignedTo],
    [System.State]
From WorkItemLinks
WHERE (
        Source.[System.TeamProject] = '$projectName'
        AND Source.[System.State] <> 'Removed'
    ) AND (
        Source.[System.WorkItemType] = 'Epic')
        AND ([System.Links.LinkType] = 'System.LinkTypes.Hierarchy-Forward'
    ) AND (Target.[System.WorkItemType] = 'UserStory') mode (Recursive)
"

$body = @{query=$query} | ConvertTo-Json
$result = Invoke-RestMethod -Uri $uri -Method Post -ContentType "application/json" -Headers @{Authorization=("Basic $base64AuthInfo")} -Body $body

修改部分代码,如下所示:

$query = "Select
    [System.Id],
    [System.WorkItemType],
    [System.Title],
    [System.AssignedTo],
    [System.State]
From WorkItemLinks
WHERE (
        Source.[System.TeamProject] = '$projectName'
        AND Source.[System.State] <> 'Removed'
    ) AND (
        Source.[System.WorkItemType] = 'Epic')
        AND ([System.Links.LinkType] = 'System.LinkTypes.Hierarchy-Forward'
    ) AND (Target.[System.WorkItemType] = 'UserStory') mode (Recursive)
"

$body = @{query=$query} | ConvertTo-Json
$result = Invoke-RestMethod -Uri $uri -Method Post -ContentType "application/json" -Headers @{Authorization=("Basic $base64AuthInfo")} -Body $body

看起来你没有做过基本的调查,甚至没有亲自尝试过?有人不太可能为您发布完整的解决方案。你自己试一试,然后回来找人帮忙填空怎么样?你用我的解决方案解决问题了吗?看起来你自己还没有做过基本的调查,甚至没有尝试过?有人不太可能为您发布完整的解决方案。不如你自己试一试,填空后发回来寻求帮助?你用我的解决方案解决问题吗?@Srini33如果我的答案解决了你的问题,你可以将其标记为答案。@Srini33如果我的答案解决了你的问题,你可以将其标记为答案。