I am working on SharePoint on-premises farm 2013 and I have a list named "LookupList", which contain a managed metadata column named "OrderName". Now I want to get the term label/name which is stored inside the managed metadata column using REST API. So I tried the following api call:-
/_api/web/lists/getbytitle('LookupList')/items?$select=OrderName,Percentage But what I got is the term GUID & term ID, but I did not get the term label/name. Here is a sample of the result I got from the above call:-
<m:properties> <d:OrderName m:type="SP.Taxonomy.TaxonomyFieldValue"> <d:Label>38</d:Label> <d:TermGuid>7*****9-a3*******d-b***7-c9********c</d:TermGuid> <d:WssId m:type="Edm.Int32">38</d:WssId> </d:OrderName> EDIT.
Now I read that I can pass CAML query inside my rest api, so inside my JavaScript code I wrote the following Ajax:-
$.ajax({ url: "/order/_api/web/lists/getbytitle('LookupList')/GetItems(query=@v1)?@v1={\"ViewXml\":\"<View><Query><Where><Eq><FieldRef%20Name='OrderName'/><Value Type='TaxonomyFieldType'>123</Value></Eq></Where></Query></View>\"}", method: "POST", async: false, headers: { "Accept": "application/json; odata=verbose" }, success: function (data) { if(data.d.results.length>0){ var items=data.d.results; for(var i=0;i<items.length;i++){ alert(items[i]); } } } }); but I got this error:-
{"error":{"code":"-2130575251, Microsoft.SharePoint.SPException","message":{"lang":"en-US","value":"The security validation for this page is invalid and might be corrupted. Please use your web browser's Back button to try your operation again."}}}
LookupListis at the subsite level.