请参阅此和此SO问题以获取背景故事。简而言之,我正在尝试在当前迭代中使用Powershell在VSTS项目中创建一个错误。
按照此处的文档,如果我在 Chrome 中访问此 URL(当然用正确的值替换(,我会得到正确的答案。 即返回列表的计数为 1,数组中只有 1 个迭代 JSON 序列化对象,具有正确的(当前(迭代。
GET https://{accountName}.visualstudio.com/{project}/{team}/_apis/work/teamsettings/iterations?$timeframe={$timeframe}&api-version=4.1
但是,如果我使用 powershell 查询相同的内容,我会得到所有迭代,而不仅仅是当前迭代。
$getCurrentIterationAPIURL = "https://account.visualstudio.com/project%20name/team/_apis/work/teamsettings/iterations?$timeframe=current&api-version=4.1"
$base64AuthInfo = [Convert]::ToBase64String([Text.Encoding]::ASCII.GetBytes(("{0}:{1}" -f $creatorUser,$createrToken)))
$getCurrentIterationResult=Invoke-RestMethod -Method GET -Uri $getCurrentIterationAPIURL -Headers @{Authorization=("Basic {0}" -f $base64AuthInfo)}
这是 API 端的错误吗(基于用户代理的不同行为,我尝试使用 Mozilla/5.0(Macintosh;Intel Mac OS X 10_10_3( AppleWebKit/537.36 (KHTML, like Gecko( Chrome/44.0.2403.89 Safari/537.36,但没有工作(或者我做错了什么?
改用这个网址:
$getCurrentIterationAPIURL = "https://account.visualstudio.com/project%20name/team/_apis/work/teamsettings/iterations?`$timeframe=current&api-version=4.1"
将$
替换为 '$