Microsoft Graph API support for new content type sync enhancements

SharePoint team

In September 2021, we changed content type publishing to improve performance and make newly published and updated content types available to sites faster. We have optimized the syncing of published content types to sites and libraries, switching from a “push everywhere” model to “pull as needed” approach. 

thumbnail image 1 of blog post titled Graph API support for new content type sync enhancements

 

Apart from the UI support to add published content types directly to a list /library/site, we are happy to announce that we are now enabling Microsoft Graph API support for fetching and syncing published content types from content type gallery or content type hub site to target sites. These APIs will enable developers to get a list of published content types in content type hub site that can be added to a list or site content type collection, add a published content type in content type hub site to a site or list content type collection, get status of all content type sync operations that will be completed asynchronously.

Documentation resources

 

Example 1: Add or sync a copy of a published content type from content type hub to a target site or a list

Request: 

POST https://graph.microsoft.com/beta/sites/{sitesId}/lists/{listId}/contentTypes/addCopyFromContentTypeHub

{ “contentTypeId”: “String” }

Response: 

HTTP/1.1 200 OK Content-Type: application/json

{ 
  "value": { 
    "@odata.type": "#microsoft.graph.contentType", 
    "id": "String (identifier)", 
    "description": "String", 
    "group": "String", 
    "hidden": "Boolean", 
    "isBuiltIn": "Boolean", 
    "name": "String" 
  } 
} 

Example 2: Asynchronous Pull 

Request:

POST https://graph.microsoft.com/beta/sites/{sitesId}/lists/{listId}/contentTypes/addCopyFromContentTypeHub

Content-Type: application/json Content-length: 33

{ “contentTypeId”: “String” }

Response:

HTTP/1.1 202 Accepted

location: https://graph.microsoft.com/beta/sites/{sitesId}/lists/{listId}/operations/{operationId}

Note: The response object shown here might be shortened for readability.

 

Example 3: Get compatible content types in content type hub that can be added to a target site or a list

Request:

GET https://graph.microsoft.com/beta/sites/{siteId}/lists/{listId}/contentTypes/getCompatibleHubContentTypes

Response:

HTTP/1.1 200 OK Content-Type: application/json

{ 
  "value": [ 
    { 
      "@odata.type": "#microsoft.graph.contentType", 
      "id": "String (identifier)", 
      "description": "String", 
      "group": "String", 
      "isBuiltIn": "Boolean", 
      "name": "String" 
    } 
  ] 
}

 

Happy coding! Sharing is caring! 🚀

More resources can be found at the Microsoft Graph Dev Center.

0 comments

Leave a comment