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) Commented Aug 27, 2019 at 15:51
  • @KasperBoLarsen Yes, it works without issues when done by hand. Both adding and changing.
    – andebor
    Commented Aug 28, 2019 at 5:57

1 Answer 1


I am surprised if you get it to work at all, the ListItemAllFields method returns a Read-Only copy of the ListItem (see the R/W table here). Use the values you get from here to get the Item ID and save that in your code, then use that to do your MERGE to https://mysite.sharepoint.com/teams/myTeam/_api/web/lists/getbytitle('Shared Documents')/items(<item id>) (list item ref here).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.