Pablo Estrada
Pablo Estrada

Reputation: 3452

Using the LoopBack API Explorer

I´ve been following some tutorials from the loopback documentation. I´m currently trying to run the API explorer by following this tutorial:

https://docs.strongloop.com/display/public/LB/Use+API+Explorer

I created a CoffeShop model. And followed the steps of creating a POST request. However, I´m getting the following 404 error.

{
  "error": {
    "name": "Error",
    "status": 404,
    "message": "There is no method to handle POST /Coffe%20Shops",
    "statusCode": 404,
    "stack": "Error: There is no method to handle POST /Coffe%20Shops\n    at restUrlNotFound (..\\hello\\node_modules\\strong-remoting\\lib\\rest-adapter.js:339:17)\n    at Layer.handle [as handle_request] (..\\hello\\node_modules\\express\\lib\\router\\layer.js:95:5)\n    at trim_prefix (..\\hello\\node_modules\\express\\lib\\router\\index.js:312:13)\n    at ..\\hello\\node_modules\\express\\lib\\router\\index.js:280:7\n    at Function.process_params (..\\hello\\node_modules\\express\\lib\\router\\index.js:330:12)\n    at next (..\\hello\\node_modules\\express\\lib\\router\\index.js:271:10)\n    at ..\\hello\\node_modules\\body-parser\\lib\\read.js:129:5\n    at invokeCallback (..\\hello\\node_modules\\raw-body\\index.js:262:16)\n    at done (..\\hello\\node_modules\\raw-body\\index.js:251:7)\n    at IncomingMessage.onEnd (..\\hello\\node_modules\\raw-body\\index.js:308:7)"
  }
}

I cloned the git repo from the tutorials and they are working fine. I have followed all the steps but I don´t know what migh be causing this error.

Can anyone help me out?

Upvotes: 1

Views: 1347

Answers (1)

joe
joe

Reputation: 2488

You're misspelling of "CoffeeShop" could be the issue. The "%20" suggests that you have put a space in the name which is throwing off loopback.

I followed the directions here:

$ git clone https://github.com/strongloop/loopback-getting-started.git
$ cd loopback-getting-started
$ git checkout step1
$ npm install

and was able to get the Post request with no problems.

enter image description here

I also created my own custom CoffeeShop persisted model and tried it again without doing a git clone on their template and had no issues:

coffee-shop.json

{  
     "name": "CoffeeShop",
     "base": "PersistedModel",
     "idInjection": true,
     "options": {
         "validateUpsert": true
     },
     "properties": {
         "name": {
             "type": "string",
             "required": true
         },
         "city": {
             "type": "string",
             "required": true
         }
     },
     "validations": [],
     "relations": {},
     "acls": [],
     "methods": {}
 }

My advice would be to compare your custom solution to the provided one by the tutorial, or quickly retry with a new project.

As stated earlier, without your code, it is hard to reproduce your exact problem, but it looks like a syntax error.

Versions:

npm 2.14.4
node 4.1.2
strongloop 6.0.0

Upvotes: 1

Related Questions