Пример #1
0
        private HttpRequestMessage PrepareRequest(HttpMethod method, object body, string path,
                                                  Dictionary <string, string> customHeaders = null)
        {
            var url = $"{_configuration.BasePath}{path}";

            var request = new HttpRequestMessage(method, url);

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

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

            if (customHeaders != null)
            {
                foreach (var header in customHeaders)
                {
                    request.Headers.Add(header.Key, header.Value);
                }
            }

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

            return(request);
        }
Пример #2
0
        private HttpRequestMessage PrepareRequest(HttpMethod method, object body, string path)
        {
            var url = $"{_configuration.BasePath}{path}";

            var request = new HttpRequestMessage(method, url);

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

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

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

            return(request);
        }