public async Task <string> CreatePersonGroup(CreatePersonGroupRequest group)
        {
            string url = $"/personGroups/{group.PersonGroupId}";

            var bodyText    = JsonConvert.SerializeObject(group);
            var httpContent = new StringContent(bodyText, Encoding.UTF8, "application/json");

            HttpResponseMessage hrm = await _client.PutAsync(url, httpContent);

            return(hrm.StatusCode.ToString());
        }
Пример #2
0
        public async Task <bool> CreatePersonGroupAsync(string personGroupId, string name, string description)
        {
            using (HttpClient client = new HttpClient())
            {
                client.DefaultRequestHeaders.Add(_ocpApimSubscriptionKey, _subscriptionKey);
                string uri = $"{_uriBase}/persongroups/{personGroupId}";
                CreatePersonGroupRequest body = new CreatePersonGroupRequest()
                {
                    Name     = name,
                    UserData = description
                };
                string              bodyText      = JsonConvert.SerializeObject(body);
                StringContent       stringContent = new StringContent(bodyText, Encoding.UTF8, "application/json");
                HttpResponseMessage response      = await client.PutAsync(uri, stringContent);

                if (!response.IsSuccessStatusCode)
                {
                    throw CreateHttpException(await response.Content.ReadAsStringAsync());
                }
                return(response.IsSuccessStatusCode);
            }
        }