public JsonResult IterationsList(string ORG, string project) { TeamDetails teams = new TeamDetails(); List <IterationDetails> iterationsList = new List <IterationDetails>(); string responseBody = ""; try { using (HttpClient client = new HttpClient()) { client.DefaultRequestHeaders.Accept.Add( new System.Net.Http.Headers.MediaTypeWithQualityHeaderValue("application/json")); client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Basic", Convert.ToBase64String( System.Text.ASCIIEncoding.ASCII.GetBytes( string.Format("{0}:{1}", "", Session["PAT"] == null ? Request.QueryString["code"] : Session["PAT"].ToString())))); using (HttpResponseMessage response = client.GetAsync("https://dev.azure.com/" + ORG + "/_apis/projects/" + project + "/teams?api-version=5.1").Result) { response.EnsureSuccessStatusCode(); responseBody = response.Content.ReadAsStringAsync().Result; teams = JsonConvert.DeserializeObject <TeamDetails>(responseBody); } } if (teams.value != null && teams.value.Count > 0) { foreach (var team in teams.value) { IterationDetails iterationDetails = new IterationDetails(); string teamname = team.name; using (HttpClient client = new HttpClient()) { client.DefaultRequestHeaders.Accept.Add( new System.Net.Http.Headers.MediaTypeWithQualityHeaderValue("application/json")); client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Basic", Convert.ToBase64String( System.Text.ASCIIEncoding.ASCII.GetBytes( string.Format("{0}:{1}", "", Session["PAT"] == null ? Request.QueryString["code"] : Session["PAT"].ToString())))); string url = "https://dev.azure.com/" + ORG + "/" + project + "/" + teamname + "/_apis/work/teamsettings/iterations?api-version=5.1"; using (HttpResponseMessage response = client.GetAsync(url).Result) { response.EnsureSuccessStatusCode(); responseBody = response.Content.ReadAsStringAsync().Result; iterationDetails = JsonConvert.DeserializeObject <IterationDetails>(responseBody); iterationDetails.teamname = teamname; iterationsList.Add(iterationDetails); } } } } } catch (Exception ex) { return(Json("")); } Session["iterationsList"] = iterationsList; return(Json(iterationsList, JsonRequestBehavior.AllowGet)); }
//"https://dev.azure.com/" + ORG + "/_apis/projects/" + project + "/teams?api-version=5.1" // public JsonResult IterationsList(string ORG, string project) public List <IterationDetails> IterationsList(string ORG, string project) { TeamDetails teams = new TeamDetails(); List <IterationDetails> iterationsList = new List <IterationDetails>(); string responseBody = ""; string api = string.Format("https://dev.azure.com/{0}/_apis/projects/{1}/teams?api-version=5.1", Org.OrganizationName, project); try { using (var client = new HttpClient()) { client.DefaultRequestHeaders.Accept.Clear(); client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json")); client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", Org.pat);//Org.pat); HttpResponseMessage response = client.GetAsync(api).Result; if (response.IsSuccessStatusCode) { var obj = response.Content.ReadAsStringAsync().Result; teams = JsonConvert.DeserializeObject <TeamDetails>(obj); } } if (teams.value != null && teams.value.Count > 0) { foreach (var team in teams.value) { IterationDetails iterationDetails = new IterationDetails(); string teamname = team.name; string url = "https://dev.azure.com/" + ORG + "/" + project + "/" + teamname + "/_apis/work/teamsettings/iterations?api-version=5.1"; using (var client = new HttpClient()) { client.DefaultRequestHeaders.Accept.Clear(); client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json")); client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", Org.pat);//Org.pat); HttpResponseMessage response = client.GetAsync(url).Result; if (response.IsSuccessStatusCode) { var obj = response.Content.ReadAsStringAsync().Result; iterationDetails = JsonConvert.DeserializeObject <IterationDetails>(obj); iterationDetails.teamname = teamname; iterationsList.Add(iterationDetails); } } } } } catch (Exception ex) { // return Json(""); return(iterationsList); } Session["iterationsList"] = iterationsList; //return Json(iterationsList, JsonRequestBehavior.AllowGet); return(iterationsList); }
public IEnumerable <IterationDetails> GetIterationDetails(string username, string password, string projectName) { rally = new Rally(username, password); var workspace = rally.GetAllWorkSpaces().Results.First(); var projects = rally.GetAllProjects(workspace); var atlas = rally.GetProject(projectName, projects); var Itrs = rally.GetItrs(atlas); List <IterationDetails> AllIterationDetails = new List <IterationDetails>(); foreach (var itr in Itrs.Results) { IterationDetails iterationDetails = new IterationDetails(); iterationDetails.Name = itr["Name"]; iterationDetails.StartDate = itr["StartDate"]; iterationDetails.EndDate = itr["EndDate"]; iterationDetails.State = itr["State"]; AllIterationDetails.Add(iterationDetails); } return(AllIterationDetails); }