I am trying to use SharePoint REST to create a content type. I intended the content type to use the 'Document' as its parent (0x0101). But every time I tried the code, it creates a content type with 'Item' as its parent(0x01).
Here is the complete code:
// URL variable
var url = _spPageContextInfo.webAbsoluteUrl
// Options variable
var options = {
headers: {
"Content-Type": "application/json;odata=verbose",
"accept": "application/json;odata=verbose",
"X-RequestDigest": _spPageContextInfo.formDigestValue
},
credentials: 'include',
method: 'POST',
body: JSON.stringify({
__metadata: {
type: "SP.ContentType"
},
Id: {
__metadata: {
type: "SP.ContentTypeId"
},
StringValue: '0x01010040C0C59A4C644983AE2877D595FC9D38'
},
Name: 'My New Document',
Description: 'My New Document',
Group: 'My New Document'
})
}
// Run fetch on the browser console.
fetch(
url + "/_api/web/contenttypes",
options
).then(
res => res.json().then(json => console.dir(json))
)
Can anyone show me what is missing?