Spark-sql- mongodb is not a valid Spark SQL Data Source

When I try to access mongodb format using spark-sql, it throws below error-

Caused by: org.apache.spark.sql.AnalysisException: mongodb is not a valid Spark SQL Data Source.

it works fine in spark-shell, please help.

This is in spark 3.4 with hive metastore.