Click here to Skip to main content
15,903,385 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Please find my client code

HttpContent content = new StringContent(data.ToString(), Encoding.UTF8, "application/json");
HttpClient client = new HttpClient(new HttpClientHandler() { UseDefaultCredentials = true });
content.Headers.ContentType = new MediaTypeWithQualityHeaderValue("application/json");
client.DefaultRequestHeaders.Accept.Add(
new MediaTypeWithQualityHeaderValue("application/json"));
string serverNameOne= "http://servername/wespapi/api/task/GetGanttTasks";
string ServerName= "http://servername/api/task/GetGanttTasks";
var response = client.PostAsync(durl1,content).Result;
return response.Content.ReadAsStringAsync().Result;


Quote:
This is my client code to call web api. All other methods are working fine with serverNameOne address. only here i have a problem. when i use ServerName without the sub root it works fine.

Exception details


InnerException {"Error while copying content to a stream."} System.Exception {System.Net.Http.HttpRequestException}


InnerException {"The request was aborted: The connection was closed unexpectedly."} System.Exception {System.Net.WebException}


Any Luck ?

What I have tried:

Try changing the url in all possible way. No luck
Posted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900