Custom API controller always returns 404 ??
# help-with-umbraco
s
Hi folk, I have a small problem, that i can't seem to figure out. My problem is, that i have created a simple controller in the backoffice, that uses the UmbracoApiController, so that the controller and endpoint should be available at host/umbraco/api/controller/endpoint. But somehow i keep getting a 404 response. I have done nothing special in the code, and i have followed the official documentation, but still the same issue occures. my class looks like this and should be available at /umbraco/api/custom/isalive public class CustomController : UmbracoApiController { public bool IsAlive() { return true; } } Any idea, as to what might be the problem?
s
There's a convention as well to start the method name with
Get
, so that the route is available using a
GET
request. If you don't want to name it
GetIsAlive
then you can decorate the method with a
[HttpGet]
attribute.
s
I found the solution. There was a metadata issue in my project, so after doing a clean repo clone and inserting the controller again, the issue was gone. I don't hope i will experience this again in the future. 2 hours down the drain.
s
Welcome to the life of a software developer 😉
s
"I don't hope i will experience this again in the future" - you will... trust me 🙂