DocumentDB REST API:从文档中提取的PartitionKey不匹配 [英] DocumentDB REST API: PartitionKey extracted from document doesn't match
问题描述
我正在尝试使用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"
),而不是分区键属性("domain"
).>
x-ms-documentdb-partitionkey: [ "domain.com" ]
执行此操作后,将返回与该分区键值匹配的文档.
I'm trying to insert a JSON document into DocumentDB via REST, using PHP (which lacks an official API wrapper). Now, it seems that a partition key has become mandatory for any collection in DocumentDB, but i cannot find the REST API documented.
I get the following error in return:
PartitionKey extracted from document doesn't match the one specified in the header
The JSON document I'm trying to insert looks as follows:
{ id:"1", ... "domain":"domain.com" }
In Azure, I have defined the collection with the following partition key:
/domain
And when sending the REST request, I send along the following header:
x-ms-documentdb-partitionkey: [ "domain" ]
What am I missing here?
For x-ms-documentdb-partitionkey
value you would need to specify the partition key value ("domain.com"
) and not the partition key attribute ("domain"
).
x-ms-documentdb-partitionkey: [ "domain.com" ]
Once you do this, documents matching this partition key value will be returned.
这篇关于DocumentDB REST API:从文档中提取的PartitionKey不匹配的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!