Insertone gives syntax error

Hi,

I am trying insertone as per m001-lesson 2.4 as below

MongoDB Enterprise Cluster0-shard-0:PRIMARY> db
video
MongoDB Enterprise Cluster0-shard-0:PRIMARY> db.moviesDetails.insertOne({title: “Star Trek II: The Wrath of Khan”, year: 1982, imdb: “tt0084726”})
2019-01-27T09:50:52.459+0530 E QUERY [js] SyntaxError: illegal character @(shell):1:35
MongoDB Enterprise Cluster0-shard-0:PRIMARY>

getting SyntaxError.

Could someone please inform what is the syntax error , I am trying exactly whats show in lesson video.

Thanks and Regards,
Prasad.

c:\M001>mongo “mongodb://cluster0-shard-00-00-lpejk.mongodb.net:27017,cluster0-shard-00-01-lpejk.mongodb.net:27017,cluster0-shard-00-02-lpejk.mongodb.net:27017/test?replicaSet=Cluster0-shard-0” --ssl --authenticationDatabase admin --username m001-student --password m001-mongodb-basics
MongoDB shell version v4.0.5
connecting to: mongodb://cluster0-shard-00-00-lpejk.mongodb.net:27017,cluster0-shard-00-01-lpejk.mongodb.net:27017,cluster0-shard-00-02-lpejk.mongodb.net:27017/test?authSource=admin&gssapiServiceName=mongodb&replicaSet=Cluster0-shard-0
2019-01-27T11:46:01.273+0530 I NETWORK [js] Starting new replica set monitor for Cluster0-shard-0/cluster0-shard-00-00-lpejk.mongodb.net:27017,cluster0-shard-00-01-lpejk.mongodb.net:27017,cluster0-shard-00-02-lpejk.mongodb.net:27017
2019-01-27T11:46:02.149+0530 I NETWORK [js] Successfully connected to cluster0-shard-00-01-lpejk.mongodb.net:27017 (1 connections now open to cluster0-shard-00-01-lpejk.mongodb.net:27017 with a 5 second timeout)
2019-01-27T11:46:02.280+0530 I NETWORK [ReplicaSetMonitor-TaskExecutor] Successfully connected to cluster0-shard-00-00-lpejk.mongodb.net:27017 (1 connections now open to cluster0-shard-00-00-lpejk.mongodb.net:27017 with a 5 second timeout)
2019-01-27T11:46:03.355+0530 I NETWORK [js] Successfully connected to cluster0-shard-00-02-lpejk.mongodb.net:27017 (1 connections now open to cluster0-shard-00-02-lpejk.mongodb.net:27017 with a 5 second timeout)
Implicit session: session { “id” : UUID(“7248cc05-50ad-4e9e-9357-923d842330fa”) }
MongoDB server version: 4.0.5
Error while trying to show server startup warnings: user is not allowed to do action [getLog] on [admin.]
MongoDB Enterprise Cluster0-shard-0:PRIMARY> db.moviesScratch.insertOne({_id: “tt0084726”,title: “Star Trek II: The Wrath of Khan”, year: 1982, imdb: “tt0084726”})
2019-01-27T11:46:29.544+0530 E QUERY [js] SyntaxError: illegal character @(shell):1:33
MongoDB Enterprise Cluster0-shard-0:PRIMARY>

I am able to successfully execute your statement in my Mongodb shell.

My hunch is that your command does not have the correct double-quote characters around the values like “tt0084726” etc. See below:

db.moviesScratch.insertOne({_id: “tt0084726”,title: “Star Trek II: The Wrath of Khan”, year: 1982, imdb: “tt0084726”})

I think in the Mongodb error message below, 1 means “Line 1” and 33 means “33rd character”:

SyntaxError: illegal character @(shell):1:33

So it is trying to tell you that the 33rd character (from the left hand side) is the problem.
Maybe you could try this: if you are copying the command from some Word processor or something similar, then copy it in a plain vanilla text editor like Notepad or Vim or Emacs.
Then make sure you replace the characters around the values to double quote characters. That’s ASCII character 34 in the ASCII table. Then run it again in the Mongodb shell.

Or maybe you could copy the command below and paste it in your Mongodb shell:

db.moviesScratch.insertOne({title: "Star Trek II: The Wrath of Khan", year: 1982, imdb: "tt0084726"})

If you still face problems, do post again.