IllegalArgumentException: requirement failed: Invalid uri

In the shell I just tried connecting to it like this:

mongosh "mongodb+srv://twittermongoinstance.db1xm.mongodb.net/twitter_data" --apiVersion 1 --username 'jmcmt87'

But what I want to do is writing my data from PySpark to the MongoDB database in Atlas, this is the command I use:

agg_df.write.format("mongo").mode("append").option("uri", mongoDB).save()

Where mongoDB variable is the following string:

'mongodb+srv://jmcmt87:<password>@twittermongoinstance.db1xm.mongodb.net/twitter_data?retryWrites=true&w=majority'