Skip to content
1 min read

Using REST to update a Managed Metadata column in SharePoint!

As a front-end developer I much prefer working with native JSON and using REST. I find the SharePoint Client Object Model (JSOM) to be a bit clunky and complicated to use. Recently I was working on a project where I had a custom form and I needed to update a Managed Metadata Field on a new document that was being uploaded. Everywhere you look on the web says... "Microsoft does not support updating Taxonomy Fields using REST". -- and while this is completely true from Microsofts point of view, there is a way you can use REST to update a Taxonomy Field. Caveat - This only works with single value Managed Metadata fields. You cannot use this method to update Multi-Value Managed Metadata fields, however you can use this one.

Lets assume I already uploaded a file in a previous method call and then I used REST to retrieve that file, to then update the Metadata (as you cannot update Metadata in the upload REST call). 


Key Notes:

 updateObject - This will be the JSON object that defines the properties on the item we are updating.

 file - this is file that was previously uploaded. I used REST to pull it. I need the file to get the __metadata structure from it.

metaObject - This is the JSON object that defines the taxonomy field. A taxonomy field needs 3 properties in its object. WssId (this can be faked with -1), TermGuid, which is the ID of the Term you've selected and Label which is the string value of the Term.

Everything should be pretty self-explanatory. I take that updateObject and add the files __metadata which defines all the attributes about the current file (item). I add the metaObject (definition of the Taxonomy values) to the updateObject. You'll notice I am also updating the Title field of the item, just to show how you would update non-Taxonomy fields.

You can see I am using a RequestExecutor because this code was being developed within a SharePoint-Hosted app and needed to access a library on a different site than the current content was. You must make sure you match your headers as above or you'll run into plenty of errors when trying to update the file.


Expert Insights from the Aerie Team

Drop us a line

Our team will be happy to answer your questions.

ADDRESS: 110 West Canal Street, Suite 201
Winooski, VT 05404

: (813) 358-4656
HOURS: 8:00 am - 5:00 pm EST Monday to Friday