Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

DocumentDB REST API: PartitionKey extracted from document doesn't match

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?

like image 538
erlangsec Avatar asked Mar 21 '17 06:03

erlangsec


1 Answers

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.

like image 141
Gaurav Mantri Avatar answered Nov 06 '22 05:11

Gaurav Mantri