Reputation: 2611
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?
Upvotes: 8
Views: 8987
Reputation: 136206
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.
Upvotes: 9