I would recommend you to get acquainted with the article Manipulating list items in SharePoint Hosted Apps using the REST API. In my opinion it is one of the best articles so far that describes how to consume SharePoint 2013 REST service in JavaScript to perform CRUD operations with list items.
Let me demonstrate you the example of creating Task item.
For that purpose let's reuse the function for creating List Item from the mentioned article:
function createListItem(webUrl,listName, itemProperties, success, failure) {
$.ajax({
url: webUrl + "/_api/web/lists/getbytitle('" + listName + "')/items",
type: "POST",
processData: false,
contentType: "application/json;odata=verbose",
data: JSON.stringify(itemProperties),
headers: {
"Accept": "application/json;odata=verbose",
"X-RequestDigest": $("#__REQUESTDIGEST").val()
},
success: function (data) {
success(data.d);
},
error: function (data) {
failure(data);
}
});
}
Note: I've added some modifications in order to specify list item
properties via function parameters
Then, the following example demonstrates how to create Task item
//Create a task item
var taskProperties = {
'Title': 'Order Approval',
'__metadata': { 'type': 'SP.Data.TasksListItem' }
};
createListItem(_spPageContextInfo.webAbsoluteUrl,'Tasks',taskProperties,
function(item){
console.log('Task "' + item.Title + '" has been created successully');
},
function(error){
console.log(error.responseText);
}
);
To summarize, in your case the error probably occurs due to
- missing or incorrect entity type name
- incorrect list item property name or value
{"error":{"code":"-2130575223, Microsoft.SharePoint.SPException","message":{"lang":"en-US","value":"This list is currently being managed by Project Web App, and cannot be edited directly"}}}
What's the meaning?