brunormoreira
brunormoreira

Reputation: 248

Problems inserting document with Mongodb and Logic Apps

My logic app collects data from an api rest and inserts into a cosmosdb mongodb. The process occurs successfully, but when performing a query using Data Explorer the following error occurs:

Error while fetching page of documents: {"code":400,"body":"Command find failed: Unknown server error occurred when processing this request."}

Here is an example of a call that reproduces the error:

"Create_or_update_document": {
                "inputs": {
                    "body": {
                        "id": "11111",
                        "name": "john",
                        "surname": "doe"
                    },
                    "host": {
                        "connection": {
                            "name": "@parameters('$connections')['documentdb']['connectionId']"
                        }
                    },
                    "method": "post",
                    "path": "/dbs/@{encodeURIComponent('cockpit')}/colls/@{encodeURIComponent('target-collection')}/docs"
                },
                "runAfter": {
                    "HTTP_2": [
                        "Succeeded"
                    ]
                },
                "type": "ApiConnection"
            }

Example input:

{
  "id": "11111",
  "name": "john",
  "surname": "doe"
}

What I've been exploring is something related to the creation of the ObjectId. Does anyone know a solution?

Upvotes: 1

Views: 1782

Answers (2)

Chris Anderson
Chris Anderson

Reputation: 8515

You can't use the Azure Cosmos DB Logic Apps connector with the MongoDB API right now. It uses the SQL REST API under the hood at the moment.

I recommend you create a simple Azure Function that does the insert for you from a MongoDB Driver in your language of choice, then call that Function from Logic Apps.

Upvotes: 3

Jay Gong
Jay Gong

Reputation: 23792

Based on the Connectors for Azure Logic Apps document,you could find the ~200+ connectors list.

Then navigate to the Azure Cosmos DB Connector, you could see the statement:

To use this integration, you will need a Cosmos DB SQL API account configured in the Azure Portal. Note that Mongo DB API accounts are not currently supported.

Upvotes: 2

Related Questions