0

I have managed to access a static url but when it comes to accessing an existing collection in mongodb (2.6) through a browser (e.g., http://0.0.0.0:8080/test/test) it returns a 404. Anybody knows if I have to add anything to the default configuration.yml to activate mongo access?

Thanks for help!!

2 Answers2

2

First make sure it is RESTHeart responding you request: if it is running on your pc, try 127.0.0.1:8080/test/test (not 0.0.0.0)

Also note that in case of 404, you should get a hal+json document with a "message" property (with somenthing like "the db test does bot exist").

If it is restheart, then either the db "test" or the collection "test/test" does not exist an you have to create them first.

If restheart coudn't connect with mongodb you would get "400 Internal Server Error" response code.

Andrea Di Cesare
  • 1,125
  • 6
  • 11
  • Thanks for the answer. 127.0.0.1:8080/test/test gives exactly the same answer, a 404 on the browser without any json. I think that it is correctly connected to mongodb (console says "Initializing MongoDB connection pool to 127.0.0.1:27017" and "MongoDB connection pool initialized"), and when accessing via mongo console I can see the database and collection. – David Geronimo Oct 27 '15 at 11:05
  • Try to use a different port: in the configuration file replace http-port: 8080 with 8090. I suspect your requests are not served by restheart – Andrea Di Cesare Oct 28 '15 at 13:45
  • Same result. In fact I was capable to connect to a static URL (after configuring static-resources), so the problem seems to be more related to mongodb... but no clue on what's wrong. – David Geronimo Oct 28 '15 at 13:55
  • Can you past your mongo-mounts configuration. Isn't that you mapped the mongodb resource under a preifx uri using the where option? If uou have where: /data then you need to request 127.0.0.1:8080/data/test/test – Andrea Di Cesare Oct 28 '15 at 19:28
  • No, the restheart is exactly as it comes, except for a new entry in the static-resources-mounts that points to a static html. Is there a way to log the http requests that are made to restheart? Setting Log-level to all does not show any request. – David Geronimo Oct 28 '15 at 21:38
  • can you past your static-resources-mounts configuration section? If the static resource 'where' property conflicts with the mongo-mounts 'where' one, then the former will take precedence. For instance, if static resources are mounted under the root /, no mongo resource can be actually accessed. The 404 in your case is returned by the FileResourceManager handler because the is no /test/test file under the directory containing the static resources (configured by the where property of the static-resources-mounts configuration object). Mount static res under a separate URI path, e.g. /resources – Andrea Di Cesare Oct 29 '15 at 08:27
1

Finally I managed to find what the problem was by myself. I post the answer in case it's helpful for somebody else. Thanks Andrea for the help in any case :)

In the static-resources-mounts I had "where: /", which seemed to collide with the mongo-mounts default own "where: /". By changing either where value the access to mongodb retrieves a correct hal+json.