My API contains 2 Get methods and 1 POST. The 2 Gets work however the POST returns this messgae:
{"Message":"The requested resource does not support http method 'GET'."}
These are my methods:
[HttpGet]
public IEnumerable<tblMetrHist> Get(string accntnum)
{
...
}
[HttpGet]
public IEnumerable<CustomerInfo> GetCustomer(string accntnum)
{
...
}
[HttpPost]
public IHttpActionResult Post([FromUri] string num, [FromUri] string reading)
{
using (CustomerEntities entities = new CustomerEntities())
{
entities.tbl1.Add(new tbl1()
{
Number = num,
Reading = reading
});
entities.SaveChanges();
}
return Ok();
}
And my Route is simply:
config.Routes.MapHttpRoute(
name: "DefaultApiWithAction",
routeTemplate: "api/{controller}/{action}"
);
So I'm not sure how to make the API recognize the method as a "Post" and not a "Get". Help please?