I have a python script that receive (from a node.js script) an _id for a mongodb document as an argument. Using that value I'm trying to query the db and retrieve a document.
However, when i try to run the script it throws an error saying
"'xxxxxxxxxx' is not a valid ObjectId, it must be a 12-byte input or a 24-character hex string".
my script where the error is causing:
result = db.req.find_one({"_id": ObjectId(sys.argv[1])})
When i check the type() of the sys.argv[1] it says str. I thought wrapping the string around ObjectId should do the trick.
value of sys.argv[1] when printed: '"5902fbdd4d2f430dfe2dded4"'
Anyone one know whats the reason causing the issue?
Thanks in advance.