404 listing rest services

Im following the rest documentation for lucee 7 on osx REST Services with Lucee :: Lucee Documentation

but it doesnt work. i get a 404 error when trying /rest/ instead of getting list of endpoints. this is my endpoint cfc script:
component rest=“true” restpath=“/test” {

/**
 * @httpMethod GET
 * @produces application/json
 */
remote struct function getTest() httpMethod="GET" produces="application/json" restpath="test" {
    return {
        "status": 200,
        "message": "GET /test executed successfully",
        "data": "Dummy data"
    };
}

}

in my Application.cfc:
public boolean function onApplicationStart() {
if (directoryExists(expandPath(“/api”))) {
restInitApplication(
dirPath=expandPath(“/api”),
serviceMapping=“api”,
default=true,
password=“abc123”
);
}
return true;
}

in my server.json i have this:
“app”:{
“cfengine”:“lucee@7”,
“restMappings”:“/rest/*”
},
when i add restMappings and try to access a cfc file in the /rest/ path i get “no rest service for [/test/test.cfc] found”.

when trying to view http://localhost:8080/rest/api/test/test i get a 404 error

does someone know whats missing that the rest api works?

I would create a new topic but i dont have the option to do so, thats why i replied to this topic.

i’ve split the topic out for you

What does your admin look like?

Rest is a bit tricky, but i’ve done a lot of work to make it well behaved

does the rest mapping work after you load a normal page which loads the application.cfc, rest services via restInitMapping only work after the application.cfc is executed, before that, the config simply isn’t loaded

1 Like

The only thing I would note with your code is since you are initializing the REST endpoint on the application start – make sure you are actually starting the application.

I have a few apps that sit out there that are static pages with REST endpoints. Often times, the REST endpoints will get hit before the static pages do. Doing that will result in a 404 error because the REST app wasn’t initialized first. Most of my apps are on Docker, so adding a healthcheck parameter on the docker/k8 config that just hits a blank .cfm page is enough to init the app and keep it warm, so the REST endpoints init properly.

If you want some examples of how the REST endpoints work, you can check out my presentation from the MMCFUG from a few years back : GitHub - quetwo/mmcfug-restpreso: MMCFUG Presentation for November 2022 on REST and ColdFusion If you end up running that example, bump the Lucee version to 7.1 in the Dockerfile and things will work just fine.