public void WorkItemTracking_Queries_GetListOfQueriesForFolder_Success() { // arrange Queries request = new Queries(_configuration); string folderPath = "Shared%20Queries/Product%20Planning"; // act ListofQueriesByFolderPath.Queries response = request.GetListOfQueriesByFolderPath(_configuration.Project, folderPath); // assert Assert.AreEqual(HttpStatusCode.OK, response.HttpStatusCode); request = null; }
// / <summary> // / get list of queries by a specific folder path // / </summary> // / <param name="project">project name or id</param> // / <param name="folderPath">folder path that must be url encoded</param> // / <returns>ListofQueriesByFolderPath.Queries</returns> public ListofQueriesByFolderPath.Queries GetListOfQueriesByFolderPath(string project, string folderPath) { ListofQueriesByFolderPath.Queries viewModel = new ListofQueriesByFolderPath.Queries(); using (var client = new HttpClient()) { client.BaseAddress = new Uri(_configuration.UriString); client.DefaultRequestHeaders.Accept.Clear(); client.DefaultRequestHeaders.Accept.Add(new System.Net.Http.Headers.MediaTypeWithQualityHeaderValue("application/json")); client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Basic", _credentials); HttpResponseMessage response = client.GetAsync(project + "/_apis/wit/queries/" + folderPath + "?$depth=2&api-version=2.2").Result; if (response.IsSuccessStatusCode) { viewModel = response.Content.ReadAsAsync <ListofQueriesByFolderPath.Queries>().Result; } viewModel.HttpStatusCode = response.StatusCode; return(viewModel); } }