cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
thomaslau
Level: Power Up

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

Hello

 

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.

 

Unauthorized.
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.

2 REPLIES 2
Community Support Team
Community Support Team

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

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.

63.PNG

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

For example:

https://f987c3c2-ccxxx-2X1-b45e.documents.azure.com:443/

The bold part is the Account ID.

 

Regards,

Michael

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.
thomaslau
Level: Power Up

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

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,

 

Thomas

Helpful resources

Announcements
firstImage

Microsoft Business Applications Virtual Launch Event

Join us for an in-depth look at the new innovations across Dynamics 365 and the Microsoft Power Platform.

firstImage

Watch Sessions On Demand!

Continue your learning in our online communities.

Power Platform 2019 Release Wave 2 Plan

Power Platform 2019 Release Wave 2 Plan

Features releasing from October 2019 through March 2020

thirdimage

Flow Community User Group Member Badge

Fill out a quick form to claim your user group badge now!

fifthimage

Microsoft Learn

Learn how to build the business apps that you need

sixthImage

Power Platform World Tour

Find out where you can attend!

seventhimage

Webinars & Video Gallery

Watch & learn from the Flow Community Video Gallery!

Users Online
Currently online: 52 members 4,555 guests
Please welcome our newest community members: