I would like to enable content types on lists with REST. Microsoft says this about these properties:

List.AllowContentTypes: Gets a value that specifies whether the list supports content types. Returns Boolean true if list supports content types otherwise returns false.

List.ContentTypesEnabled: Gets or sets a value that specifies whether content types are enabled for the list. Returns Boolean true if content types are enabled for the list otherwise returns false.

It looks like AllowContentTypes is used as a getter only, while ContentTypesEnabled is used to set or get the value.

However I was reading how to change content types in code, and the REST request used by Microsoft docs is like this:

  url: "<app web url>/_api/SP.AppContextSite(@target)/web
    ?@target='<host web url>'",
  method: "POST",
  body: "{ '__metadata': { 'type': 'SP.List' }, 'AllowContentTypes': true, 'BaseTemplate': 100,
    'ContentTypesEnabled': true, 'Description': 'My list description', 'Title': 'Test title' }",
  headers: { 
    "IF-MATCH”: "*",
    "X-HTTP-Method": "MERGE",
    "content-type": "application/json;odata=verbose"
  success: successHandler,
  error: errorHandler

So they're using the AllowContentTypes (the one which was supposed to be a getter), to update the list to allow content types.

Can anyone explain this please? What should I be using and why?

Thanks all!


I don't understand what your question here is. However, I will put here all I know related to this.

As you already said, AllowContentTypes determines if you can manage content types (updating an existing content type or creating a new content type) in a particular list. For example, lists of type Survey, Wiki page library etc do not support content type management. So they will have AllowContentTypes set to false.

And in case, if you try to update ContentTypesEnabled to true when AllowContentTypes value is false for a particular list, it throws an exception like this "This list does not allow content types"

Coming to ContentTypesEnabled, setting this to true allows the user to create/update content types present in that list.

FYR Stackoverflow answer

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.