i wish to add item to share Point hosted list from from share Point hosted app itself.here i tried something with the help of rest API's but that is not working,so how can i do this??
1 Answer
CREATE Operation
listName: The name of the list you want to get items from
weburl: The url of the web that the list is in.
newItemTitle: New Item title.
success: The function to execute if the call is sucesfull
failure: The function to execute if the call fails
function CreateListItemWithDetails(listName, webUrl, newItemTitle, success, failure) {
var itemType = GetItemTypeForListName(listName);
var item = {
"__metadata": { "type": itemType },
"Title": newItemTitle
};
$.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()
},
success: function (data) {
success(data);
},
error: function (data) {
failure(data);
}
});
-
i tried the same but here the hosted list name is missing,for the list name there i am getting 404 error,but when i m creating a list manualy insite site collection with same name then this code is workingMadhav– Madhav2016-06-01 08:17:34 +00:00Commented Jun 1, 2016 at 8:17