Im trying to update a column for a document in a document library in Sharepoint Online with the Sharepoint Rest API. I'm not very familiar with Sharepoint in general, but after a few days of struggle I've finally managed to update some managed metadata.
I've successfully been able to update a few documents with the following, but I'm getting inconsistent results.
payload:
{
"MyCoolField": {
"Label": "20.0015-LANGMOEN",
"TermGuid": "6ed9cf13-5ffe-466b-873c-3485f9a651cb",
"WssId": 25,
"__metadata": {
"type": "SP.Taxonomy.TaxonomyFieldValue"
}
},
"__metadata": {
"type": "SP.Data.Shared_x0020_DocumentsItem"
}
}
headers:
headers = {
"Content-Length": str(len(json.dumps(payload))),
"Accept": "application/json; odata=verbose",
"Content-Type": "application/json; odata=verbose",
"X-RequestDigest": jsonDigestValue,
"IF-MATCH": "*",
"X-HTTP-Method": "MERGE"
}
I'm posting this to https://mysite.sharepoint.com/teams/myTeam/_api/Web/GetFileByServerRelativeUrl('/teams/myTeam/Shared Documents/dir/afile.pdf')/ListItemAllFields
and get a 204 response. In some cases the document metadata gets updated with the term label and in some cases it doesn't. I've also tried to update one that already has a value. When I do that, nothing happens, but I still get a 204 response.
I don't understand what's happening. Is there some hidden mechanism I'm not aware of? Any help would be greatly appreciated.