Problem with Ticket Database Connection

I set up the application locally on my machine. I modified the application.properties as explained in the course and I’m able to run the associated unit test successfully.
When I run the application it loads well on the browser (at least I’m able to see some movies on the page) but when I go to the status page and try to validate the connection test I get the error "Connection: The return from the api was incorrect"

Did I miss something.

Any help???

1 Like

Hi @Vincent_Douwe,

Welcome to the MongoDB Community Forums, :sparkles:

I think it is happening due to a mismatch in the dataset or there is some modification to the unit test cases from your side. If yes, then kindly undo the changes in the test cases
else
Kindly remove all the data and reload it from the Atlas → Load Sample Data again.

Hope it helps! :slightly_smiling_face:

Thanks,
Kushagra

Hello,

It is really weird. The only file I modified in the project is the application.properties file. I loaded the sample data again as you suggested but the result is still the same. I even tried with a local installation of mongodb 4 on my computer without more luck.

Please share the content of

Here is the content of application.properties

jwtSecret=SECURITYISVERYHARD
jwtExpirationInMs=604800000
spring.mongodb.uri=mongodb://localhost:27017/
spring.mongodb.database=sample_mflix
server.port=5000
server.error.whitelabel.enabled=true
logging.level.api.controllers=DEBUG
api.movies.movies_per_page=21
spring.resources.static-locations=classpath:/META-INF/resources/,classpath:/resources/,classpath:/static/,classpath:/build

Why

The course uses Atlas as the database. At least it did when I took the course.

Hello,

I started with Atlas but since it was not working I tried my local mongodb database.
Here is the application.properties file using Atlas

jwtSecret=SECURITYISVERYHARD
jwtExpirationInMs=604800000
   spring.mongodb.uri=mongodb+srv://m220student:m220password@mflix.2vakd.mongodb.net/test
spring.mongodb.database=sample_mflix
server.port=5000
server.error.whitelabel.enabled=true
logging.level.api.controllers=DEBUG
api.movies.movies_per_page=21
spring.resources.static-locations=classpath:/META-INF/resources/,classpath:/resources/,classpath:/static/,classpath:/build

The connection string is correct and the cluster appears to be configured correctly.

May be the extra space you have before spring.mongodb.uri is the culprit. Computers are not as smart as human to guess what you want to do when misspelling or formatting errors are present.

You will need to post a screenshot of your terminal when you are running the connection test for us to help you further.

Hello Steevej,

Thanks for your reply.

In the application.properties file there is not space before spring.mongodb.uri (this is a formatting problem that arises when I copy the content here).

I decided to move forward with the course, and I was able to pass the two following tickets. It is bizarre.

Here is a screenshot of my terminal when I run the ConnectionTest.

Thanks again

It looks like you are on the right path.

Start a new thread if you face any new issues.