VSTS API List Iterations (current timeframe) not working in powershell

孤街浪徒 提交于 2019-12-11 23:37:18

问题


See this and this SO question for the back story. In short, I am trying to create a bug in a VSTS project using powershell in the current iteration.

Following the documentation here, if I visit this URL in Chrome (substituted with right values of course) I get the right answer. i.e. the returned list's count is 1 and there is only 1 iteration json serialized object in the the array with the right (current) iteration.

GET https://{accountName}.visualstudio.com/{project}/{team}/_apis/work/teamsettings/iterations?$timeframe={$timeframe}&api-version=4.1

However, if I use powershell to query the same, I get ALL iterations and not just the current one.

$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)}

Is this a bug on the API side (different behavior based on UserAgent, I tried to specify a UserAgent with 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, but didn't work) or what am I doing wrong ?


回答1:


Using this url instead:

$getCurrentIterationAPIURL = "https://account.visualstudio.com/project%20name/team/_apis/work/teamsettings/iterations?`$timeframe=current&api-version=4.1"

Replace $ to `$



来源:https://stackoverflow.com/questions/50710424/vsts-api-list-iterations-current-timeframe-not-working-in-powershell

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!