I am using C# HttpClient to call the GET web service. However, I am encountering this InnerException : The server committed a protocol violation. Section=ResponseHeader Detail=CR must be followed by LF in.
I tried using WebClient as well, but it had the same issue. The Solution to set useUnsafeHeaderParsing is not an option for me.
I used Fiddler to debug, it shows 200 status code with the returned data. My take on this is the issue is not with the request but with the GetAsync method.
I not am able to make any further progress in solving it. Any help would be highly appreciated.
using (HttpClient client = new HttpClient())
{
       var builder = new UriBuilder("http://url/abc/xyz?..");
       builder.Port = -1;
       var query = HttpUtility.ParseQueryString(builder.Query);
       query["param_1_key"] = "param_1";
       query["param_2_key"] = "param_2";
       query["param3_key"] = "param_3_value";
       builder.Query = query.ToString();
       string url = builder.ToString();
       client.BaseAddress = new Uri(url);
       client.DefaultRequestHeaders.Clear();
       client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
       var byteArray = Encoding.ASCII.GetBytes("username" + ":" + "password");
       var str = Convert.ToBase64String(byteArray);
       client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Basic", Convert.ToBase64String(byteArray));
       response = client.GetAsync(builder.Uri.AbsoluteUri).Result;
}