Rupesh Kahane

Rupesh Kahane

  • 102
  • 19.1k
  • 4.2m

getting Internal Server Error when call a Web API by async

Nov 7 2016 7:13 AM
I have created an Web API application.
This application I have hosted on one server.
 
Now I am calling a post method of that (hosted ) application using async call in another application, so If I put a debugger then I am getting an Internal Server Error when call a Web API by async.
Bellow is my code
public async void PostRequest(string name)
{
try
{
string name = "rupesh";
Uri requestUri = new Uri("http://xxxxx:2565/api/Registration/SignUp"); //replace your Url
string json = "";
json = Newtonsoft.Json.JsonConvert.SerializeObject(name);
var objClint = new System.Net.Http.HttpClient();
System.Net.Http.HttpResponseMessage respon = await objClint.PostAsync(requestUri, new StringContent(json, System.Text.Encoding.UTF8, "application/json"));
string responJsonText = await respon.Content.ReadAsStringAsync();
}
catch (Exception ex)
{
var er = ex.Message.ToString();
}
}
 
Give me some solution.
Thanks 

Answers (3)