function CreateListItemWithDetails(listName, newItemBody) {
var item = newItemBody;
return $.ajax({
url: _spPageContextInfo.siteAbsoluteUrl + "/_api/web/lists/getbytitle('" + listName + "')/items",
type: "POST",
contentType: "application/json;odata=verbose",
data: JSON.stringify(item),
headers: {
"Accept": "application/json;odata=verbose",
"X-RequestDigest": $("#__REQUESTDIGEST").val(),
"content-Type": "application/json;odata=verbose"
}
});
}
CreateListItemWithDetails(listName, newItemBody)
.then(function(data){
//success callback
var NewlyCreatedItemId = data.d.ID;
}, function(data){
//failure callback
});