示例#1
0
        public void SendBug(IBug bug)
        {
            HttpClient httpClient = this.GetHttpClient();

            httpClient.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
            httpClient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Basic",
                                                                                           Convert.ToBase64String(
                                                                                               Encoding.ASCII.GetBytes(
                                                                                                   string.Format("{0}:{1}", this._username, this._password))));
            var method  = new HttpMethod("PATCH");
            var request = new HttpRequestMessage(method, this._requestUrl)
            {
                Content = new StringContent(bug.Deserialize(), Encoding.UTF8, "application/json-patch+json")
            };
            HttpResponseMessage hrm = httpClient.SendAsync(request).Result;

            Response = hrm.Content;
        }