I have a SharePoint list which has managed meta data field& lookup field. I want to retrieve the field values and show in HTML table format using rest api.

  • Can you explain more ? Jan 8 '20 at 20:14
  • I have a country field which is managed metadata. How to form the rest query?
    – Liz
    Jan 9 '20 at 2:50

The SharePoint REST API has a little... I don't know what to call it - extension method? - anyway, an endpoint called FieldValuesAsText which will give you what you want.

I haven't used it too much, but from just now playing around with it a bit in Postman, it seems like in order for it to work properly, you will need to know the ID of the list item you are getting the values for, and you will have to make individual calls for each item if you are trying to get more than one. It looks something like this:

/_api/web/lists/getbytitle('Your List')/items(12)/FieldValuesAsText

Then in the result object, it will have the regular internal field names as the properties, but the values of both lookup fields and managed metadata fields will be the text label value you are looking for.

I tried to get the values for multiple list items at the same time by doing

/_api/web/lists/getbytitle('Your List')/items?$select=FieldValuesAsText&$expand=FieldValuesAsText

but that didn't work as expected. The FieldValuesAsText property of the result objects was populated (i.e. expanded), but in that, the values of the lookup and managed metadata fields were the term or lookup IDs, not the text label values.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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