无法通过逻辑应用更新 Cosmos DB

Unable to update CosmosDB via LogicApps

我不确定为什么我在尝试使用逻辑应用程序更新 CosmosDB 中的文档时经常遇到以下错误:

  1. 从文档中提取的 PartitionKey 与 header
  2. 中指定的不匹配
  3. 其中一个指定的输入无效

对于错误 1,我通过 LogicApps 发送了以下请求:

{
    "method": "post",
    "headers": {
        "x-ms-documentdb-is-upsert": "True",
        "x-ms-documentdb-raw-partitionkey": "12347"
    },
    "path": "/dbs/bc-gamification-management/colls/bcpoints/docs",
    "host": {
        "connection": {
            "name": <omitted as this shouldn't matter>
        }
    },
    "body": {
        "curr_point": 500,
        "id": "12347",
        "overall_point": 1400
    }
}

不太确定我是从哪里得到这个想法的,但是对于错误 2,我从 body 请求中省略了分区键:

{
    "method": "post",
    "headers": {
        "x-ms-documentdb-is-upsert": "True",
        "x-ms-documentdb-raw-partitionkey": "12347"
    },
    "path": "/dbs/bc-gamification-management/colls/bcpoints/docs",
    "host": {
        "connection": {
            "name": <omitted as this shouldn't matter>
        }
    },
    "body": {
        "curr_point": 500,
        "overall_point": 1400
    }
}

我尝试使用以下方法对此进行故障排除:https://docs.microsoft.com/en-us/azure/cosmos-db/sql/troubleshoot-bad-request 和各种其他方法,例如在 分区键值 中使用“id”和“/id”而不是分区键的实际值。但是所有这些方法都不起作用,我不太清楚为什么...

仅供参考,CosmosDB 具有以下示例的项目:

{
    "id": "12347",
    "overall_point": 1200,
    "curr_point": 300,
    "_rid": <omitted as this shouldn't matter>,
    "_self": <omitted as this shouldn't matter>,
    "_etag": <omitted as this shouldn't matter>,
    "_attachments": <omitted as this shouldn't matter>,
    "_ts": <omitted as this shouldn't matter>
}

“id”字段也是 Collection 的分区键。请指教:")

你需要的是这样的东西

{
    "method": "post",
    "headers": {
        "x-ms-documentdb-is-upsert": "True",
        "x-ms-documentdb-raw-partitionkey": "\"12347\""
    },
    "path": "/dbs/testdb/colls/testcoll/docs",
    "host": {
        "connection": {
            "name": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
        }
    },
    "body": {
        "curr_point": 500,
        "id": "12347",
        "overall_point": 1400
    }
}

您需要将分区键放在引号内,就像这样。