SOLVED

Create Content Types programmatically or import massively

%3CLINGO-SUB%20id%3D%22lingo-sub-1719038%22%20slang%3D%22en-US%22%3ECreate%20Content%20Types%20programmatically%20or%20import%20massively%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1719038%22%20slang%3D%22en-US%22%3E%3CP%3EHi%2C%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI've%20been%20trying%20to%20use%20the%20Rest%20API%20to%20create%20Content%20Types%20without%20luck%20(as%20it%20seems%20there's%20a%20bug%20which%20Microsoft%20is%20not%20willing%20to%20fix)%3A%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Fgithub.com%2Fpnp%2Fpnpjs%2Fissues%2F457%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%22%3Ehttps%3A%2F%2Fgithub.com%2Fpnp%2Fpnpjs%2Fissues%2F457%3C%2FA%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EAlso%2C%20there's%20no%20documented%20way%20to%20do%20the%20same%20through%20the%20Graph%20API.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3ESo%2C%20do%20you%20guys%20know%20any%20way%20to%20create%20Content%20Types%20massively%20or%20import%20them%20in%20a%20similar%20way%20it's%20done%20through%20the%20new%20Term%20Store%3F%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThanks!%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-1719038%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EAdmin%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3ESharePoint%20Online%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1719362%22%20slang%3D%22en-US%22%3ERe%3A%20Create%20Content%20Types%20programmatically%20or%20import%20massively%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1719362%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F685390%22%20target%3D%22_blank%22%3E%40andres101%3C%2FA%3E%26nbsp%3BTry%20creating%20content%20types%20with%20PowerShell%2C%3CBR%20%2F%3E%3CBR%20%2F%3EAdd-PnPContentType%20-Name%20%22%3CNAME%3E%20%22%20-Description%20%22%3CDESCRIPTION%3E%22%20-Group%20%22%3CGROUP%20name%3D%22%22%3E%22%20-ParentContentType%20%3CPARENT%20content%3D%22%22%20type%3D%22%22%3E%3CBR%20%2F%3E%3CBR%20%2F%3EThen%20you%20can%20add%20fields%20to%20that%20specific%20content%20type%3A%3CBR%20%2F%3E%3CBR%20%2F%3EAdd-PnPField%20-DisplayName%20%22%3CDISPLAY%20name%3D%22%22%3E%22%20-InternalName%20%22%3CINTERNAL%20name%3D%22%22%3E%22%20-Type%20%3CFIELD%20type%3D%22%22%3E%20-Group%20%22%3CSAME%20group%3D%22%22%20as%3D%22%22%20the%3D%22%22%20content%3D%22%22%20type%3D%22%22%3E%22%3C%2FSAME%3E%3C%2FFIELD%3E%3C%2FINTERNAL%3E%3C%2FDISPLAY%3E%3C%2FPARENT%3E%3C%2FGROUP%3E%3C%2FDESCRIPTION%3E%3C%2FNAME%3E%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1719646%22%20slang%3D%22en-US%22%3ERe%3A%20Create%20Content%20Types%20programmatically%20or%20import%20massively%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1719646%22%20slang%3D%22en-US%22%3E%3CP%3EHey!%20Thanks%20for%20your%20response.%3CBR%20%2F%3E%3CBR%20%2F%3ECould%20you%20provide%20be%20with%20a%20link%20to%20the%20powershell%20documentation%20related%20to%20this%3F%20My%20background%20is%20Web%20Development%20and%20I%20have%20no%20experience%20with%20Microsoft%20PowerShell.%3CBR%20%2F%3EAlso%2C%20note%20that%20it%20should%20be%20able%20to%20work%20with%20SharePoint%20%3CSTRONG%3EOnlilne%3C%2FSTRONG%3E%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1720918%22%20slang%3D%22en-US%22%3ERe%3A%20Create%20Content%20Types%20programmatically%20or%20import%20massively%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1720918%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F685390%22%20target%3D%22_blank%22%3E%40andres101%3C%2FA%3E%26nbsp%3BThis%20works%20well%20with%20SharePoint%20Online!%20%3A)%3C%2Fimg%3E%20Could%20you%20please%20mark%20my%20previous%20post%20as%20best%20answer%20if%20it%20was%20what%20you%20were%20looking%20for%3F%26nbsp%3B%3CBR%20%2F%3E%3CBR%20%2F%3EHere%20is%20the%20link%3A%26nbsp%3B%3CBR%20%2F%3E%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fpowershell%2Fmodule%2Fsharepoint-pnp%2Fadd-pnpcontenttype%3Fview%3Dsharepoint-ps%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%20noopener%20noreferrer%22%3Ehttps%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fpowershell%2Fmodule%2Fsharepoint-pnp%2Fadd-pnpcontenttype%3Fview%3Dsharepoint-ps%3C%2FA%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EIf%20you%20need%20any%20more%20assistance%2C%20please%20notify%20me.%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E
Highlighted
Occasional Contributor

Hi,

 

I've been trying to use the Rest API to create Content Types without luck (as it seems there's a bug which Microsoft is not willing to fix): https://github.com/pnp/pnpjs/issues/457

 

Also, there's no documented way to do the same through the Graph API.

 

So, do you guys know any way to create Content Types massively or import them in a similar way it's done through the new Term Store?

 

Thanks!

4 Replies
Highlighted

@andres101 Try creating content types with PowerShell,

Add-PnPContentType -Name "<name> " -Description "<description>" -Group "<group name>" -ParentContentType <parent content type (to fetch default columns)>

Then you can add fields to that specific content type:

Add-PnPField -DisplayName "<display name>" -InternalName "<internal name>" -Type <field type> -Group "<same group as the content type>"

Highlighted

Hey! Thanks for your response.

Could you provide be with a link to the powershell documentation related to this? My background is Web Development and I have no experience with Microsoft PowerShell.
Also, note that it should be able to work with SharePoint Onlilne

Highlighted
Best Response confirmed by andres101 (Occasional Contributor)
Solution

@andres101 This works well with SharePoint Online! :) Could you please mark my previous post as best answer if it was what you were looking for? 

Here is the link: 
https://docs.microsoft.com/en-us/powershell/module/sharepoint-pnp/add-pnpcontenttype?view=sharepoint...

 

If you need any more assistance, please notify me. 

Highlighted
I've been looking into the docs and haven't been able to test it yet, but it looks promising!