I am trying to create a list in SP2013 REST. This is what I get
var url = "http://mysite/_api/web/lists";
$.ajax({
url: url,
type: "POST",
contentType: "application/json;odata=verbose",
body: {
'__metadata': {
'type': 'SP.List'
},
'AllowContentTypes': true,
'BaseTemplate': 100,
'ContentTypesEnabled': true,
'Description': 'My list description',
'Title': 'Test123'
},
cache: false,
headers: {
"Authorization" : "Bearer123",
"X-RequestDigest": $("#__REQUESTDIGEST").val(),
"Accept": "application/json;odata=verbose",
"content-type": "application/json;odata=verbose",
"content-length" : 800
},
beforeSend : function(jqXHR, settings) {
},
success: function (data) {
alert(data);
},
error: function (jqxr, errorCode, errorThrown) {
alert("Failed");
}
});
But it doesn't seem to work. The MSDN page is not that helpful since it doesn't give a jquery example, and I can't find any good examples anywhere.
https://msdn.microsoft.com/en-us/library/office/dn292552.aspx
Does anyone know to do it?
with the above, it seems to be returning
"{\"error\":{\"code\":\"-1, Microsoft.SharePoint.Client.InvalidClientQueryException\",\"message\":{\"lang\":\"en-US\",\"value\":\"A node of type 'EndOfInput' was read from the JSON reader when trying to read the start of an entry. A 'StartObject' node was expected.\"}}}"
Thanks