The partition key supplied in x-ms-partitionkey header has fewer components than defined in the the collection

If you have been trying to write a document to CosmosDB and are getting this error message, try the following:

In the CodeView on the Azure Portal, you will no doubt see a body section within the JSON similar to this

What you might find, is that, a header section may be missing, or at least the x-ms-documentdb-partitionkey header is missing. In which case, you should try to add it in via JSON, similar to

Note, on occasions when receiving this error message, I noticed that my partition key header was defined as x-ms-documentdb-raw-partitionkey. You may find it necessary to toggle this.