Articles about European Sharepoint Hosting Service
SharePoint 2013 Hosting – HostForLIFE.eu : How To Read SharePoint TermStore (Managed Metadata) Using REST API?
SharePoint itself provides a REST API for each site you create. It is such wonderful thing to help the developers manipulate maximum areas of SharePoint like accessing lists, settings, users, user groups, navigation, etc. through the application that you built. Since there are some restrictions and threshold limits are always there in SharePoint to improve performance we cannot access some areas of SharePoint through Rest API. But still it is possible to access it by using SharePoint’s old web service methodology (until Microsoft deprecated it).
Let’s see the workaround to use SharePoint’s old web service methodology to get the TermStore Data with step by step instructions.
Step 1
Create a Managed Metadata field in any List and map the respective term set item with it, like below.
Step 2
Now, using REST API get the field information of the Managed Metadata column which you have created in the previous step so we could be able to get the SspId and TermSetId in the field XML of the list.
Rest API Url : {HostUrl}/_api/Web/Lists/getbytitle(‘{ListName}’)/fields/getbytitle(‘{FieldInternalName}’)?$select=SspId,TermSetId
The output will be like below: (SspId and TermSetId were highlighted)
Note – Since we need only these two values, I have queried only those fields in ODATA query $select=SspId,TermSetId in above url, if you want to read all field information, you can use ,*.
Step 3
Now, by passing these SspId and TermSetId, we need to make a SOAP call to invoke SharePoint web service to get the Term Set Data. Here, we are going to post the input data in XML format so please mention the content-type in the headers as “text/xml” along with the authorization headers.
The post body will look like below. Replace the highlighted values with respective ids.
WebService URL: {HostUrl}/_vti_bin/taxonomyclientservice.asmx?op=GetTermSets
Request Body
Finally, we will get the expected output in XML format and parse the XML to deserialize API response, sample output format is mentioned below.
Print article | This entry was posted by Peter on July 5, 2018 at 5:07 am, and is filed under European SharePoint 2013 Hosting. Follow any responses to this post through RSS 2.0. You can leave a response or trackback from your own site. |