DocumentDB REST API: x-ms-documentdb-partitionkey is invalid

99封情书 提交于 2019-12-10 18:43:53

问题


I am attempted to get a Document from DocumentDB using the REST API. I am using a partitioned Collection and therefore need to add the "x-ms-documentdb-partitionkey" header. If I add this, I get "Partition key abc is invalid". I can't find anywhere in the documentation that expects the key to be in specific format, but simply supplying the expected string value does not work. Does anyone know the expected format?


回答1:


Partition key must be specified as an array (with a single element). For example:

x-ms-documentdb-partitionkey: [ "abc" ]



回答2:


Partition key for a partitioned collection is actually the path to a property in DocumentDB. Thus you would need to specify it in the following format:

/{path to property name} e.g. /department

From Partitioning and scaling in Azure DocumentDB:

You must pick a JSON property name that has a wide range of values and is likely to have evenly distributed access patterns. The partition key is specified as a JSON path, e.g. /department represents the property department.

More examples are listed in the link as well.



来源:https://stackoverflow.com/questions/40423437/documentdb-rest-api-x-ms-documentdb-partitionkey-is-invalid

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!