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.


  "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 = {
    "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.

  • Does your Managed metadata field work when updating it by hand? I have raised a support case with Microsoft regarding errors when updating a managed metadata field ( seems only to be an issue for targeted Release for the time being) – Kasper Bo Larsen Aug 27 at 15:51
  • @KasperBoLarsen Yes, it works without issues when done by hand. Both adding and changing. – andebor Aug 28 at 5:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.