400 error when getting the countries

the query works when I connect to the mongo shell:
({‘countries’: {’$in’: [‘Australia’]}}, {‘title’: 1})

python code:
myquery = {“countries”: { “$in”:countries} },{ “title”: 1}
return list(db.movies.find(myquery))

message on the console after calling the test on the status page. - - [21/Aug/2019 18:32:25] “GET /api/v1/movies/countries?countries=Australia HTTP/1.1” 400 -

thank you for the help

Hi @asalineroj,

Query seems fine to me!

This code does not work for me.

Did the unit tests pass? If yes, then please share the output here.

Also, you can try doing this in one line like:

return list(db.movies.find({“countries”: { “$in”:countries} },{ “title”: 1}))


@asalineroj, if you want to use a variable like myquery, which I like to do to, I would use 2 variables. One for the query and one for the projection. And then call find( myquery , myprojection ).


Hello Kanika,

Thank you for your support, I saw that the 400 error was coming from a typo in the .ini file, so the URI for the database was not getting set properly when connecting the driver from the python app to the mongoDB.

Thank you


Once I got the URI fixed, this worked a treat

Thank you so much!

1 Like