SharePoint Term Store APIs (Part Three of a Three Part Term Store Series)

SharePoint Term Store APIs 

(Part Three of a Three Part Term Store Series)

Store Groups Endpoint:
  1. (GET) {BASE_URL}/termStore/groups
  2. (GET) {BASE_URL}/termStore/termGroups?$select=*,oneDrive.rights&filter=(type eq ‘RegularGroup’ or type eq ‘SystemGroup’)
  3. (GET) {BASE_URL}/termStore/termGroups?$select=*,oneDrive.rights&filter=(type eq ‘SiteCollectionGroup’)

This first endpoint returns term groups from both global and site collection-specific term stores.

To get term groups from a specific term store we can use either the second or the third endpoint.

Term Sets Endpoint:

  1. (GET) {BASE_URL}/termStore/termGroups/{GROUP_ID}/termSets?$select=*,oneDrive.rights

Furthermore, this endpoint returns term sets associated with the group. We need to pass the group ID returned from the groups’ endpoint to make this call.

Terms Endpoint:

  1. (GET) {BASE_URL}/termStore/termSets/{TERM_SET_ID}/getlegacychildren?$select=*,oneDrive.rights

Also, this endpoint returns all terms under the term set. We need to pass the term set ID returned from the term sets endpoint. Please note that it does not return sub-terms of the terms, but instead just returns all items on the first level of the root (i.e., the requested term set).

Sub Terms Endpoint:
  1. (GET) {BASE_URL}/termStore/termSets/{TERM_SET_ID}/terms/{TERM_ID}/getlegacychildren?$select=*,oneDrive.rights

This endpoint returns all first-level sub-terms under a requested term. Another key point, we need to pass a term ID returned from the previous term endpoint. Please note that for all subsequent nested terms we can use this endpoint, just changing the requested term ID.

Note:

  • rights: selecting this field would specify the exact rights on the requested resource. (i.e., Store, Group, Term Set, or Term)

Search Terms:

  1. (GET) {BASE_URL}/termStore/searchTerm(label=’value’,languageTag=’en-US’)?$expand=set

In addition, this endpoint searches exhaustively on all term stores (global and site collection specific) for all terms matching the requested label.

Add Terms Endpoint:
    1. (POST) {BASE_URL}/termStore/termGroups/{GROUP_ID}/termSets/{TERM_SET_ID}/children
    2. (POST) {BASE_URL}/termStore/termGroups/{GROUP_ID}/termSets/{TERM_SET_ID}/terms/{TERM_ID}/children

    (payload) => { isDefault: true, languageTag: “en-US”, name: “testterm3”}

    This first endpoint is used to add first-level terms to a term set. But the second endpoint is used to add successive subterms to the requested term ID.

Update Terms Endpoint:
    1. (PATCH) {BASE_URL}/termStore/termSets/{TERM_SET_ID}/terms/{TERM_ID}

    (payload) => { isDefault: true, languageTag: “en-US”, name: “testterm3-updated”}

    This endpoint is used to update the value of the requested term in a specified term set.

    Delete Terms Endpoint:

    1. (DELETE) {BASE_URL}/termStore/termSets/{TERM_SET_ID}/terms/{TERM_ID}

    However, this endpoint is used to delete the term and all sub-terms under the requested term.

Term Group:

Add Term Group (Site Collection)

  1. (POST) {BASE_URL}/termStore/groups
    (payload) => { name: “testgroup2”, type: “SiteCollectionGroup”, scope: “siteCollection”}

This endpoint is used to add a term group to a site collection level. Please note that we can only have one term group on a site collection.

Update Term Group

  1. (PATCH) {BASE_URL} /termStore/termGroups/{GROUP_ID}
    (payload) => { name: “testgroup2” }

This endpoint is used to update the requested term group.

Delete Term Group

  1. (DELETE) {BASE_URL} /termStore/termGroups/{GROUP_ID}

Then this endpoint is used to delete the requested term group. Please note that a Term group can only be deleted if there are no term sets associated with it.

Term Set:

Add Term Set

  1. (POST) {BASE_URL} /termStore/termGroups/{GROUP_ID}/termSets
    (payload) => { localizedNames : [ { “name“: “testtermset1”, “languageTag“: “en-US” } ] }

This endpoint is used to add one or multiple term sets to a requested group. Please note that we cannot pass multiple term sets objects in the array.

Update Term Set

  1. (PATCH) {BASE_URL} /termStore/termSets/{TERM_SET_ID}
    (payload) => { localizedNames : [ { “name“: “testtermset1”, “languageTag“: “en-US” } ] }

Additionally, this endpoint is used to update the requested term set.

Delete Term Set

  1. (DELETE) {BASE_URL} /termStore/termGroups/{GROUP_ID}/termSets/{TERM_SET_ID}

Furthermore, this endpoint is used to delete the requested term set under a term group.

That’s it for this SharePoint Term Store series! Lastly, remember to check our second blog, Obtaining an Authentication Token to Access SharePoint Term Store APIs. And for a refresher on the basics, check out our first blog from the series: Getting Started with SharePoint Term Store.

 

In conclusion, did you know that Bamboo Solutions offers M365 products, as well as, services? Lastly, find out more at our website or contact us to discuss how we can help you make the most of SharePoint, the term store, and M365!