Add content type to SharePoint List/Library using REST API Use this below code to add content type to SharePoint Library using REST API. For this you need to use the content type ID. Below function will get the content type ID from content type name & we will pass the content type id to next function which will update content type to list/library. var varContentTypeName = " Your Content Type name "; var Listname = " Your List name where you want to add content type "; //This will get the content type ID from content type Name function getContentTypeID() { var deferred = $.Deferred(); var isCurrentUserIsApprover = false ; var serverURL = _spPageContextInfo.webAbsoluteUrl; var listURL = String.format(" {0}/_api/web/AvailableContentTypes?$select=Name,Id,StringId&$filter=Name eq '"+varContentTypeName+"' ",serverURL); $.ajax({ url: listURL, type: " GET ", async: false, headers:...
Comments
Post a Comment