public async Task <LargePersonGroup> CreateLargePersonGroupAsync() { #region code HttpClient client = new HttpClient(); // Request headers client.DefaultRequestHeaders.Add("Ocp-Apim-Subscription-Key", _azCVSettings.Key); LargePersonGroup largePersonGroup = new LargePersonGroup(); largePersonGroup.Name = "GAB2021"; largePersonGroup.LargePersonGroupId = Guid.NewGuid().ToString(); largePersonGroup.RecognitionModel = "recognition_04"; var uri = _azCVSettings.Endpoint + "/face/v1.0/largepersongroups/" + largePersonGroup.LargePersonGroupId; HttpResponseMessage response = await client.PutAsync(uri, new StringContent(JsonConvert.SerializeObject(largePersonGroup), Encoding.UTF8, "application/json")); if (response.StatusCode == System.Net.HttpStatusCode.OK) { return(largePersonGroup); } #endregion return(null); }
private async void OnAddPersonGroupButtonClicked(object sender, RoutedEventArgs e) { try { if (string.IsNullOrEmpty(SettingsHelper.Instance.WorkspaceKey)) { throw new InvalidOperationException("Before you can create groups you need to define a Workspace Key in the Settings Page."); } Guid personGroupGuid = Guid.NewGuid(); await FaceServiceHelper.CreateLargePersonGroupAsync(personGroupGuid.ToString(), this.personGroupNameTextBox.Text, SettingsHelper.Instance.WorkspaceKey); LargePersonGroup newGroup = new LargePersonGroup { Name = this.personGroupNameTextBox.Text, LargePersonGroupId = personGroupGuid.ToString() }; this.PersonGroups.Add(newGroup); this.personGroupsListView.SelectedValue = newGroup; this.personGroupNameTextBox.Text = ""; this.addPersonGroupFlyout.Hide(); this.needsTraining = true; } catch (Exception ex) { await Util.GenericApiCallExceptionHandler(ex, "Failure creating group"); } }