SOLVED

REST API bug when retrieving managed metadata list field configured to allow single values?

%3CLINGO-SUB%20id%3D%22lingo-sub-117711%22%20slang%3D%22en-US%22%3EREST%20API%20bug%20when%20retrieving%20managed%20metadata%20list%20field%20configured%20to%20allow%20single%20values%3F%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-117711%22%20slang%3D%22en-US%22%3E%3CP%3EHi%20everyone%2C%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EAny%20suggestion%20on%20this%20problem%20would%20be%20much%20appreciated.%3C%2FP%3E%3CP%3EI'm%20trying%20to%20load%20all%20the%20items%20from%20a%20list%20that%20contains%20some%20managed%20metadata%20fields%20using%20the%20REST%20api.%3C%2FP%3E%3CP%3EThe%20API%20returns%20back%20an%20Id%20in%20place%20of%20the%20Label%20value%3C%2FP%3E%3CP%3EThe%20list%20is%20located%20on%20a%20sub%20web%2C%20so%20I%20can't%20play%20with%20T%3CSPAN%3EaxCatchAll%3C%2FSPAN%3E%3C%2FP%3E%3CP%3EThe%20fields%20are%20configured%20to%20store%20single%20values.%20If%20set%20to%20multi%20values%2C%20the%20API%20returns%20the%20correct%20term%20Label%2C%20although%2C%20changing%20the%20fields%20is%20not%20an%20option%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThis%20feels%20more%20like%20a%20bug%20on%20the%20API%20to%20me...Anyone%20experienced%20this%20before%3F%26nbsp%3B%3C%2FP%3E%3CP%3EAny%20ideas%20on%20how%20to%20handle%20this%26nbsp%3Bscenario%20within%20the%20REST%20api%3F%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EMany%20thanks%3C%2FP%3E%3CP%3EJoel%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-117771%22%20slang%3D%22en-US%22%3ERe%3A%20REST%20API%20bug%20when%20retrieving%20managed%20metadata%20list%20field%20configured%20to%20allow%20single%20values%3F%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-117771%22%20slang%3D%22en-US%22%3E%3CP%3EHi%20Andrew%2C%20thanks%20for%20your%20reply!%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3ETo%20be%20honest%2C%20I%20was%20really%20surprised%20to%26nbsp%3Bnever%20come%20across%20this%20limitation%20before%20%3A)%3C%2Fimg%3E%3C%2FP%3E%3CP%3EI%20did%20found%20some%20blog%20posts%20describing%20the%20CAML%26nbsp%3Bworkaround%2C%20but%26nbsp%3Bbetween%20that%20and%20the%20JSOM%2C%20I%20ended%20up%20with%20JSOM.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EJoel%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-117769%22%20slang%3D%22en-US%22%3ERe%3A%20REST%20API%20bug%20when%20retrieving%20managed%20metadata%20list%20field%20configured%20to%20allow%20single%20values%3F%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-117769%22%20slang%3D%22en-US%22%3E%3CP%3EHi%20Joel%2C%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThis%20is%20a%20well-known%20issue%20since%202013.%3C%2FP%3E%3CP%3ESingle-valued%20MMD%20columns%20just%20can%20be%20retrieved%20as%20desired%20with%20OData%2C%20with%20Multi-valued%20MMD%20columns%20it%20is%20much%20better.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EBut%20there%20is%20a%20workaround.%20There%20is%20a%20possibility%20of%20getting%20single%3CSPAN%3E-valued%20MMD%20columns'%20values%20while%20items%20request%20if%20do%20it%20with%20%60%3C%2FSPAN%3EgetItemsByCAMLQuery%3CSPAN%3E%60%20list's%20method.%20It's%20a%20part%20of%20REST%20API%2C%20is%20an%20implementation%20for%20backward%20compatibility.%20The%20downside%20of%20the%20approach%20is%20that%20OData%20configurators%20like%20(%24select%2C%20%24filter%2C%20%24expand%20and%20so%20on)%20can't%20be%20used%20together%20with%26nbsp%3BOData.%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%3CSPAN%3E--%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%3CSPAN%3ERegards%2C%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%3CSPAN%3EAndrew%3C%2FSPAN%3E%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-117749%22%20slang%3D%22en-US%22%3ERe%3A%20REST%20API%20bug%20when%20retrieving%20managed%20metadata%20list%20field%20configured%20to%20allow%20single%20values%3F%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-117749%22%20slang%3D%22en-US%22%3E%3CP%3EI%20have%20now%20gave%20up%20and%20used%20JSOM%20to%20load%20the%20data...although%26nbsp%3BI%20would%20still%20like%20to%20hear%20suggestions%20if%20you%20have%20come%20across%20this%20scenario%20before.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EIn%20case%20you%20are%20working%20with%20SPFx%20web%20parts%20and%20need%20to%20use%20JSOM%20for%20some%20reason%20(REST%20is%20the%20recommended%20approach%20and%20I%20trust%20everyone%20will%20understand%20why)%2C%20this%20article%20provides%20excellent%20guidance%20on%20how%20to%20quickly%20setup%20everything%20and%20get%20started%3C%2FP%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fsharepoint%2Fdev%2Fspfx%2Fweb-parts%2Fguidance%2Fconnect-to-sharepoint-using-jsom%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3Ehttps%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fsharepoint%2Fdev%2Fspfx%2Fweb-parts%2Fguidance%2Fconnect-to-sharepoint-using-jsom%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EJoel%3C%2FP%3E%3C%2FLINGO-BODY%3E
MVP

Hi everyone,

 

Any suggestion on this problem would be much appreciated.

I'm trying to load all the items from a list that contains some managed metadata fields using the REST api.

The API returns back an Id in place of the Label value

The list is located on a sub web, so I can't play with TaxCatchAll

The fields are configured to store single values. If set to multi values, the API returns the correct term Label, although, changing the fields is not an option

 

This feels more like a bug on the API to me...Anyone experienced this before? 

Any ideas on how to handle this scenario within the REST api?

 

Many thanks

Joel

 

 

3 Replies

I have now gave up and used JSOM to load the data...although I would still like to hear suggestions if you have come across this scenario before.

 

In case you are working with SPFx web parts and need to use JSOM for some reason (REST is the recommended approach and I trust everyone will understand why), this article provides excellent guidance on how to quickly setup everything and get started

https://docs.microsoft.com/en-us/sharepoint/dev/spfx/web-parts/guidance/connect-to-sharepoint-using-... 

 

Joel

best response confirmed by Joel Rodrigues (MVP)
Solution

Hi Joel,

 

This is a well-known issue since 2013.

Single-valued MMD columns just can be retrieved as desired with OData, with Multi-valued MMD columns it is much better.

 

But there is a workaround. There is a possibility of getting single-valued MMD columns' values while items request if do it with `getItemsByCAMLQuery` list's method. It's a part of REST API, is an implementation for backward compatibility. The downside of the approach is that OData configurators like ($select, $filter, $expand and so on) can't be used together with OData.

 

--

Regards,

Andrew

Hi Andrew, thanks for your reply!

 

To be honest, I was really surprised to never come across this limitation before :)

I did found some blog posts describing the CAML workaround, but between that and the JSOM, I ended up with JSOM.

 

Joel