Workaround for correctly retrieving Single select taxonomy field Label value via REST

Problem:

I have list names “Experts” with a Metadata Column as ContosoLevel. When I retrieve the column via REST call I get only following in the response for the column.

“ContosoLevel”:{“__metadata”:{“type”:”SP.Taxonomy.TaxonomyFieldValue”},“Label”:”1″,”TermGuid”:”47dd115d-7399-46d1-b985-205e499bbbdd”,”WssId”:1}

I was expecting the Label field will have the term value.

REST Call: GET /sites/PankajSandBox/_api/web/lists/getByTitle(‘Experts’)/items

Also I noticed that when I change the column as MultiSelect, the REST call works.

Solution:

The solution to use the POST method with the CAML query. The single select values will be returned. Please make sure you pass the “X-RequestDigest” value in your POST request.

Once I followed the steps. I was able to get the values as following.

“ContosoLevel”:{“__metadata”:{“type”:”Collection(SP.Taxonomy.TaxonomyFieldValue)”},”results”:[{“Label”:”Chief Engineer”,”TermGuid”:”47dd115d-7399-46d1-b985-205e499bbbdd”,”WssId”:1}]}

REST Call: POST /sites/PankajSandBox/_api/web/lists/getByTitle(‘Experts’)/GetItems(query=@v1)?@v1={‘ViewXml’:'<View><Query></Query></View>’}

Please see the following blog which helped me.

http://sharepointificate.blogspot.co.uk/2014/05/taxonomy-columns-sharepoint-2013-list.html?showComment=1411555297896&_sm_au_=iFVS4N0LQ7sf9STj

About Pankaj

I am a Developer and my linked profile is https://www.linkedin.com/in/pankajsurti/
This entry was posted in SharePoint 2010, SharePoint 2013. Bookmark the permalink.

1 Response to Workaround for correctly retrieving Single select taxonomy field Label value via REST

  1. Shiva says:

    “Also I noticed that when I change the column as MultiSelect, the REST call works”, Thanks for the sentence it saved my day !

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s