I'm on a project where I'm implementing a CRUD for a Sharepoint 2013 Document Library which includes two custom content types, the default one I'll call MyDoc which is derived from Document and another type I'll call MyDocSet which is derived from Document Set. I'm doing this with JS/jQuery.
I can't seem to figure out how to set the content type when creating a list item. I want to add an item of content type MyDocSet, but it always wants to assume the default content type.
Here is my unsuccessful attempt:
var executor = new SP.RequestExecutor(baseUrl);
var bodyContent = JSON.stringify({
"__metadata": {"type": "SP.Data.LineJSubmitItem"},
//How to set content type ID?
});
executor.executeAsync({
url: baseUrl + "/sites/linej/_api/web/lists/GetByTitle('LineJSubmit')/items",
method: "POST",
headers: {
"Accept": "application/json;odata=verbose",
"content-type": "application/json;odata=verbose",
"X-RequestDigest": formDigestValue,
"content-length": bodyContent.length,
},
body: bodyContent,
success: function(data) {
alert("success");
},
error: function(data, errorCode, errorMessage) {
var jsonObject = JSON.parse(data.body);
var errMsg = jsonObject.error.message.value;
alert(errMsg);
}
});