Reputation: 65
We are developing api for our SQL Server tables. The WebApiConfig class is as follows:
public static class WebApiConfig
{
public static void Register(HttpConfiguration config)
{
ODataModelBuilder builder = new ODataConventionModelBuilder();
builder.EntitySet<CRMUser>("User");
config.MapODataServiceRoute(routeName:"ODataRoute",
routePrefix: null,
model: builder.GetEdmModel());
}
}
The controller is as follows:
public class UsersController : ODataController
{
// GET api/<controller>
OnlineStoreEntities db = new OnlineStoreEntities();
protected override void Dispose(bool disposing)
{
db.Dispose();
base.Dispose(disposing);
}
public IEnumerable<CRM_vwUser> Get()
{
return db.CRM_vwUser;
}
// GET api/<controller>/5
public string Get(int id)
{
return "value";
}
// POST api/<controller>
public void Post([FromBody]string value)
{
}
// PUT api/<controller>/5
public void Put(int id, [FromBody]string value)
{
}
// DELETE api/<controller>/5
public void Delete(int id)
{
}
}
But we got error while browsing this url "http://localhost:50246/User". The error is as follows:
No HTTP resource was found that matches the request URI 'http://localhost:50246/user'. No type was found that matches the controller named 'User'.
Upvotes: 0
Views: 727
Reputation: 14389
You controller name is UsersController
(with an S) and in your URL you set ../User
as well as in
builder.EntitySet<CRMUser>("User");
Try setting Users
in your URL and Entity Set,or change Controller to UserController
Upvotes: 1