/// <summary>
        /// Send Http Post to request uri and get HttpResponseMessage
        /// </summary>
        public static async Task <HttpResponseMessage> PostAsJsonAsync(Uri requestUri, IDictionary <string, string> headers, object content)
        {
            // Create new request function
            Func <HttpRequestMessage> createRequestMessage = () =>
            {
                // Create new request
                HttpRequestMessage request = new HttpRequestMessage(HttpMethod.Post, requestUri);

                // Add headers to request
                request.AddHeaders(headers);

                // Add content as Json
                request.AddContentAsJson(content);

                return(request);
            };

            // Post request
            HttpResponseMessage response = await ExecuteActionkWithAutoRetry(() => Client.SendAsync(createRequestMessage()));

            return(response);
        }
Example #2
0
        /// <summary>
        /// Send Http Post to request uri and get HttpResponseMessage
        /// </summary>
        public static async Task <HttpResponseMessage> PostAsJsonAsync(string requestUri, IDictionary <string, string> headers, object content, bool camelCasePropertyNames, CancellationToken cancellationToken)
        {
            // Create new request function
            HttpRequestMessage createRequestMessage()
            {
                // Create new request
                var request = new HttpRequestMessage(HttpMethod.Post, requestUri);

                // Add headers to request
                request.AddHeaders(headers);

                // Add content as Json
                request.AddContentAsJson(content, camelCasePropertyNames);

                return(request);
            }

            // Post request
            var response = await ExecuteActionkWithAutoRetry(() => Client.SendAsync(createRequestMessage(), cancellationToken));

            return(response);
        }