Search This Blog

Sunday, May 19, 2019

Turning off .net core Transfer-Encoding Chuked automatic header

                var objectContent = new ObjectContent<Dictionary<string, DataTable>>(dataTablesDic, new JsonMediaTypeFormatter(), "application/json");
                var json = Newtonsoft.Json.JsonConvert.SerializeObject(dataTablesDic);
                //setting request's content ContentLength's header was the only way I found to turn off .net core automatic Transfer-Encoding=Chunked setting, which was resulting in web api post object binding failure
                objectContent.Headers.ContentLength = Encoding.UTF8.GetByteCount(json);
                var result = httpClient.PostAsync($"http://localhost:65000/File/GetExcel?bucketDestinationPath={fileName}&S3bucketName=myBuketName", objectContent)?.Result;

No comments:

Post a Comment