1

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 1

1

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);
    }
});
1
  • 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 working Commented Jun 1, 2016 at 8:17

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.