If you're using Azure CosmosDB, you can go to Azure Portal -> CosmosDB -> Select your CosmosDB Instance -> Features
There you'll find RetyableWrites set to either True or False. Change it according to your requirement.
This fixed my issue.