Showing results for 
Search instead for 
Did you mean: 
New Member

Fail to create document to Azure cosmos db by cosmos db connector (authorization)



I have try to setup microsoft flow cosmos db connector to save data (create document) to Azure cosmos db.


During the setup, I have input the db account name and access key to microsoft flow connection copied from Azure cosmos db.

In the microsoft flow cosmos db connector, I can select database and collection name which implied that my Azure cosmos db key is correct and microsoft flow can connect to cosmos db. And I confirmed that this is a read-write key but not a read-only key.


However, when I run the flow, microsoft flow shows the following error.


Status code 401


"The input authorization token can't serve the request. Please check that the expected payload is built as per the protocol, and check the key being used."


What should I do to solve the authorization issue above?

Thank you very much.

Community Support
Community Support

Hi @thomaslau,


This might be caused by the authentication.

Please click on the Azure cosmos DB action, then verify you have the proper connection choosed.


Further, verify your connection information again, the Account ID should be: Name of the account without '' part.

For example:

The bold part is the Account ID.




Community Support Team _ Michael Shao
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Hi Michael @v-micsh-msft ,


Thank you for your information.

I have checked my connection information including Account ID which the input data is correct according to the instruction.

And as mentioned, after the setup of connection, I can choose database and collection from the pull down selection box which implied the connection information for Microsoft flow is correct.


I found one of issue from database type. At the very beginning, I have chosen Azure Cosmos DB (MongoDB) which only provide a password-liked key. However, according to many online resource, it shows that I should input the secondary key in Microsoft flow Cosmos DB connection setup. For Cosmos DB (MongoDB) type, Microsoft flow has the above issue if I input the key from Cosmos DB (MongoDB) [connection can get database/collection information but does not have authroization to create document].


When I create another database by Azure Cosmos DB (SQL) and I fill in the secondary key in connection inforomation (Microsoft flow), and I try to enter a fixed text JSON in document of "create document" (Microsoft flow), I can create a document and save to Azure Cosmos DB (SQL). I believe that the existing Microsoft flow should work with Azure Cosmos DB (SQL) but not the Azure Cosmos DB (MongoDB) on document creation due to authorization issue.

My workflow gets the infromation from jpg by Face API and store into Azure Cosmos DB. When I runs the workflow, the Cosmos DB connector to Azure Cosmos DB (SQL) shows error (An action failed. No dependent actions succeeded.). As my understanding, it means that the Face API is fail and does not have any information to Cosmos DB.


However, in the history of Face API, it shows success (status: 200) with normal output (Face API JSON).

Then, I removed the Cosmos DB connector. I added Gmail, and also MSSQL connector after Face API for testing.
Both Gmail and MSSQL conector can get Face API information successfully.
I believe that the Cosmos DB connector may have some issues to retrieve data from previous action.
Would you kindly advise?

Thanks & Regards,



Helpful resources

Microsoft 365 Conference – December 6-8, 2022

Microsoft 365 Conference – December 6-8, 2022

Join us in Las Vegas to experience community, incredible learning opportunities, and connections that will help grow skills, know-how, and more.

Users online (2,000)