首页 文章

DocumentDB REST API:从文档中提取的PartitionKey不匹配

提问于
浏览
6

我正在尝试使用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" ]

我在这里想念的是什么?

1 回答

  • 5

    对于 x-ms-documentdb-partitionkey 值,您需要指定分区键值( "domain.com" )而不是分区键属性( "domain" ) .

    x-ms-documentdb-partitionkey: [ "domain.com" ]

    执行此操作后,将返回与此分区键值匹配的文档 .

相关问题