web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Automate / Fail to create documen...
Power Automate
Unanswered

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

(0) ShareShare
ReportReport
Posted on by 4

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.

Categories:
I have the same question (0)
  • v-micsh-msft Profile Picture
    on at

    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

  • thomaslau Profile Picture
    4 on at

    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

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Automate

#1
Michael E. Gernaey Profile Picture

Michael E. Gernaey 522 Super User 2025 Season 2

#2
Tomac Profile Picture

Tomac 364 Moderator

#3
abm abm Profile Picture

abm abm 243 Most Valuable Professional

Last 30 days Overall leaderboard