I am having some troubles with an asp.net WebApi project. I am using the rtm bits.
Within my api controller I have this
[HttpPut]
public Business Update([FromBody]Business business)
{
try
{
if (business.Id == Guid.Empty)
{
throw new HttpResponseException(HttpStatusCode.BadRequest);
}
return _repository.Update(business);
}
catch (Exception ex)
{
log4net.ILog log = log4net.LogManager.GetLogger(this.GetType());
log.Info(string.Format("Update Error Business"));
log.Info(ex);
throw;
}
}
My mvc4 application I am calling this api method from a repository within my application
public static HttpResponseMessage Put(string apiMethod,string baseAddress,object objectData)
{
var myHttpClient = new HttpClient
{
BaseAddress = new Uri(baseAddress)
};
myHttpClient.DefaultRequestHeaders.Authorization = new BasicAuthenticationHeaderValue("username", "Password1");
myHttpClient.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
var put = myHttpClient.PutAsJsonAsync(apiMethod, objectData);
var x = put.Result;
return x;
}
I keep getting a server 500 error. I have a breakpoint on the api controller and its not getting hit. If a manually call the api from a 3rd party tool the api is called.
I have checked all of the basic things but can't seem to figure out whats going on.
Anyone got any tips I can use to figure out whats going wrong?