I am trying to create a new iteration to Visual Studio Team Services, initially by just writing code using LINQPad. However I do not understand the API documentation in terms of the payload I need to pass to VSTS.
Intuitively I thought you should pass the name of the iteration and so on but this failed. The API documentation seems to indicate you pass in an id with a guid
"{\"id\":\"a589a806-bf11-4d4f-a031-c19813331553\"}";
but then I get back the following:
{"$id":"1","innerException":null,"message":"Specified argument was out of the range of valid values.\r\nParameter name: iteration.Id","typeName":"System.ArgumentOutOfRangeException, mscorlib, Version=14.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089","typeKey":"ArgumentOutOfRangeException","errorCode":0,"eventId":0}
This says to me that an iteration with this id doesn't exist. I would like to create a new iteration. What I do know is that my account doesn't have permission but I was hoping that my investigation would end in a message to indicate that and I could take the script to my manager and go forward from there.
Here is the code I am using
void Main(){
string credentials = Convert.ToBase64String(System.Text.ASCIIEncoding.ASCII.GetBytes(string.Format("{0}:{1}", "", Util.GetPassword("vsts.access"))));
//use the httpclient
using (var client = new HttpClient())
{
client.BaseAddress = new Uri("https://{instance}.visualstudio.com:"); //url of our account
client.DefaultRequestHeaders.Accept.Clear();
client.DefaultRequestHeaders.Accept.Add(new System.Net.Http.Headers.MediaTypeWithQualityHeaderValue("application/json"));
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Basic", credentials);
//var postBody = "{\"id\":\"" + System.Convert.ToString(Guid.NewGuid()) + "\"}";
var postBody = "{\"id\":\"a589a806-bf11-4d4f-a031-c19813331553\"}";
//connect to the REST endpoint
HttpResponseMessage response = client.PostAsync("DefaultCollection/{Team}/_apis/work/TeamSettings/Iterations?api-version=v2.0",new StringContent(postBody, Encoding.UTF8, "application/json")).Result;
response.Content.ReadAsStringAsync().Result.Dump();
}
}
Any help would be much appreciated. I'm pretty new to this area so I apologise if this is a schoolboy error on my part but I'm really stuck and cannot find any posts of anyone who has done the same.
Thanks,
Sunil