VSTS API List Iterations (current timeframe) not w

2019-09-03 08:27发布

问题:

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 `$