【发布时间】:2017-03-21 06:29:16
【问题描述】:
我正在尝试使用 PHP(缺少官方 API 包装器)通过 REST 将 JSON 文档插入 DocumentDB。现在,似乎对于 DocumentDB 中的任何集合都必须使用分区键,但我找不到记录的 REST API。
我得到以下错误作为回报:
PartitionKey extracted from document doesn't match the one specified in the header
我尝试插入的 JSON 文档如下所示:
{ id:"1", ... "domain":"domain.com" }
在 Azure 中,我使用以下分区键定义了集合:
/domain
在发送 REST 请求时,我会发送以下标头:
x-ms-documentdb-partitionkey: [ "domain" ]
我在这里错过了什么?
【问题讨论】:
-
您需要指定分区键值而不是属性,即您将编写
x-ms-documentdb-partitionkey: [ "domain.com" ]。请试试这个。 -
成功了!!非常感谢! (请将您的回复添加为答案 - 不要评论 - 这样我可以设置接受/已解决)
-
澄清:分区集合需要分区键,而不是单分区集合。
标签: azure azure-cosmosdb