Quantcast
Channel: Developing Apps for SharePoint 2013 forum
Viewing all articles
Browse latest Browse all 8089

Not able to insert a record in a list using REST

$
0
0

My app has a list

This is the code which I have written to insert a record in this list

function test() { var listUrl = appWebUrl + "/_api/web/lists/getbytitle('BookCatalog')/items"; var itemType = GetItemTypeForListName('BookCatalog'); var item = new Object(); item.type = itemType; var reco = { __metadata: item, Title: "Hellojhjkhk", Category1: "Worldjjlk", ISBN10: "123457868", ISBN13: "12345897979", Image: "http://ts2.mm.bing.net/th?id=H.4919052866749229&pid=1.7&w=216&h=188&c=7&rs=1" }; console.log(JSON.stringify(reco)); $.ajax({ url: listUrl, type: "POST", contentType: "application/json;odata=verbose", data: JSON.stringify(reco), headers: { "Accept": "application/json; odata=verbose", "X-RequestDigest": $("#__REQUESTDIGEST").val() }, success: function (data) { console.log("+++ insert success ++++") }, error: function (data, errorCode, errorMessage) { console.log("+++ insert fail ++++"); console.log(data.responseText); showError(errorMessage); } }); }

function GetItemTypeForListName(name) {
    return "SP.Data." + name.charAt(0).toUpperCase() + name.slice(1) + "ListItem";
}




val it: unit=()





Viewing all articles
Browse latest Browse all 8089

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>