コード例 #1
0
        private static HttpRequestMessage PrepareRequest(HttpMethod method, object body, StringBuilder urlBuilder)
        {
            var request = new HttpRequestMessage(method, urlBuilder.ToString());

            request.Headers.Add("User-Agent", UserAgent);

            request.Headers.Add("Accept", "application/json");

            if (body != null)
            {
                var         content        = new JsonRequestContent(body, new JsonSerializer());
                HttpContent requestContent = content.GetContent();
                request.Content = requestContent;
            }

            return(request);
        }
コード例 #2
0
        private static HttpRequestMessage PrepareRequest(HttpMethod method, object body, StringBuilder urlBuilder)
        {
            var request = new HttpRequestMessage(method, urlBuilder.ToString());

            request.Headers.Add("User-Agent", UserAgent);

            request.Headers.Add("Accept", "application/json");

            if (body != null)
            {
                var content = new JsonRequestContent(body, new JsonSerializer());
                HttpContent requestContent = content.GetContent();
                request.Content = requestContent;
            }

            return request;
        }