private async void GetWorkItemTypesBehaviors(GetWorkItemTypesBehaviorsEventArgs args) { try { using (HttpClient client = new HttpClient()) { Results.InitializeHttpClient(client, args.Organization.PAT); // TODO(crhodes) // Update Uri Use args for parameters. var requestUri = $"{args.Organization.Uri}/_apis" + $"/work/processes/{args.Process.id}/" + $"/workitemtypesbehaviors/{args.WorkItemType.referenceName}" + "/behaviors" + "?api-version=6.1-preview.1"; var exchange = Results.InitializeExchange(client, requestUri); using (HttpResponseMessage response = await client.GetAsync(requestUri)) { Results.RecordExchangeResponse(response, exchange); response.EnsureSuccessStatusCode(); string outJson = await response.Content.ReadAsStringAsync(); JObject o = JObject.Parse(outJson); WorkItemTypesBehaviorsRoot resultRoot = JsonConvert.DeserializeObject <WorkItemTypesBehaviorsRoot>(outJson); Results.ResultItems = new ObservableCollection <WorkItemTypesBehavior>(resultRoot.value); IEnumerable <string> continuationHeaders = default; bool hasContinuationToken = response.Headers.TryGetValues("x-ms-continuationtoken", out continuationHeaders); Results.Count = Results.ResultItems.Count; } } } catch (Exception ex) { Log.Error(ex, Common.LOG_CATEGORY); ExceptionDialogService.DisplayExceptionDialog(DialogService, ex); } EventAggregator.GetEvent <HttpExchangeEvent>().Publish(Results.RequestResponseExchange); }
private async void GetWidgets(GetWidgetsEventArgs args) { try { using (HttpClient client = new HttpClient()) { Results.InitializeHttpClient(client, args.Organization.PAT); var requestUri = $"{args.Organization.Uri}/{args.Project.id}/{args.Team.id}/_apis/dashboard/dashboards/{args.Dashboard}?api-version=6.1-preview.1"; //var exchange = Results.InitializeExchange(client, requestUri); var exchange = Results.InitializeExchange(client, requestUri); using (HttpResponseMessage response = await client.GetAsync(requestUri)) { Results.RecordExchangeResponse(response, exchange); response.EnsureSuccessStatusCode(); string outJson = await response.Content.ReadAsStringAsync(); JObject o = JObject.Parse(outJson); //WidgetsRoot resultRoot = JsonConvert.DeserializeObject<WidgetsRoot>(outJson); //Widgets.ResultItems = new ObservableCollection<Domain.Widget>(resultRoot.value); IEnumerable <string> continuationHeaders = default; bool hasContinuationToken = response.Headers.TryGetValues("x-ms-continuationtoken", out continuationHeaders); Results.Count = Results.ResultItems.Count; } } } catch (Exception ex) { Log.Error(ex, Common.LOG_CATEGORY); ExceptionDialogService.DisplayExceptionDialog(DialogService, ex); } EventAggregator.GetEvent <HttpExchangeEvent>().Publish(Results.RequestResponseExchange); }