On my console application I am making following webClient
Request to upload the data.
using (var client = new WebClient())
{
client.Headers.Clear();
client.Headers.Add("Content-Type", "application/json; charset=utf-8");
client.UploadStringCompleted += (data, exception) =>
{
if (exception.Error != null)
{
_log.Error("Error While Posting XYZSets data {0}", exception.Error);
}
client.Dispose();
};
var ApplicationUrl = string.Format("{0}/api/AAA/PostXYZSets", ConfigurationManager.AppSettings["ApplicationUrl"]);
client.UploadStringAsync(new Uri(ApplicationUrl), jsonData);
}
In my MVC application at some point I am returning the IHttpActionResult
by following code.
[ServiceAuthentication]
public IHttpActionResult PostXYZSets(XYZSet[] xYZSets)
{
return BadRequest("My Custom Error message");
}
But when UploadStringCompleted
method receives exception, I nowhere find "My Custom Error message". it says (400) Bad Request.
Tell me what's wrong am i doing. thanks in advance.