I attempted so as to add a brand new content material kind to record utilizing MS Graph Explorer:
Request:
POST https://graph.microsoft.com/v1.0/websites/{site-id}/lists/{list-id}/contenttypes
with physique:
{
"description": "MyCustomContentType's description",
"group": "Record Content material Sorts",
"hidden": false,
"id": "0x010300B8123BA6FE3D6045BF4F6DF992B6ABE7",
"identify": "MyCustomContentType",
"parentId": "0x0103",
"readOnly": false,
"sealed": false
}
Response:
{
"error": {
"code": "itemNotFound",
"message": "The desired web site content material kind was not discovered",
"innerError": {
"request-id": "1ac12fed-eaf3-4d03-a3c4-b44ddacada72",
"date": "2020-05-16T17:12:11"
}
}
}
Additionally tried this with Graph API sdk in Java code:
IGraphServiceClient graphClient = GraphServiceClient.builder()
.authenticationProvider(authenticationProvider)
.buildClient();
ContentType contentType = new ContentType();
contentType.identify = "MyCustomContentType";
contentType.description = "MyCustomContentType's description";
contentType.group = "Record Content material Sorts";
contentType.hidden = false;
contentType.parentId = "0x0103";
contentType.id = "0x010300B8123BA6FE3D6045BF4F6DF992B6ABE7";
contentType.readOnly = false;
contentType.sealed = false;
contentType = graphClient.websites(siteId)
.lists(listId)
.contentTypes()
.buildRequest()
.submit(contentType);
the end result is identical…
Additionally I attempted so as to add content material kind to record utilizing REST API however confronted with one other downside: content material kind is created nevertheless it ignores handed id and at all times inherited from Merchandise content material kind. Identical downside described right here: The right way to create a SharePoint content material kind with 'Doc' because the guardian. It looks as if a bug of REST API.
Is it potential to create content material kind in SharePoint utilizing MS Graph or REST API? Possibly there are one other methods to create it utilizing Java?
Thanks!
PS: This query is a duplicate of my query from StackOverflow: https://stackoverflow.com/questions/61842382/how-to-create-a-new-content-type-in-sharepoint-using-ms-graph-rest.