Error while using the function Create
viktor-morin opened this issue · 6 comments
While creating a document you get an error that x-ms-documentdb-partitionkey
is missing in the header.
By adding following:
if id != "" { r.Header.Add("x-ms-documentdb-partitionkey", fmt.Sprintf("[ \"%s\" ]", id)) }
The problem get solved. I have just extended the method (just fixed it locally), but I assume its better to read the property Id if needed from the object itself.
I have the same issue @a8m.
@viktor-morin mind sharing how you fixed this?
To add some context: Partition Keys are now mandatory: MicrosoftDocs/azure-docs#20882 I can't figure out how to add the partition key header in the library, however (and the partition key should not be the ID of the document)
If I remeber correctly I added that line here:
Line 127 in f1cda92
@viktor-morin thanks for responding. I figured out just a couple of minutes ago that the code is available today, but only in the "master" branch. So, when running a normal "go get", it will fetch the v1.0.0 tag which doesn't support adding headers like these.
The method that works for me, after pulling the code with @master, is:
func (u *DocumentDB) Add(document *Document) (err error) {
pk := documentdb.PartitionKey(document.User)
_, err = conn.CreateDocument(u.coll.Self, document, pk)
return
}
Hey guys,
Sorry for the troubles. I've added a new release tag (v.1.1.0).
Would you mind update the README?
Thanks
Thanks @a8m - I'll check this out tonight.
PS: Given the large amount of changes and the fact that they're not backwards-compatible, shouldn't this have been 2.0?