Saturday 12 July 2014

SharePoint REST Update List Item

update: function (id, lname, fname, wphone) {
$.ajax(
{
url: _spPageContextInfo.webServerRelativeUrl +
"/_api/web/lists/getByTitle('Contacts')/getItemByStringId('" +
id + "')",
type: "POST",
contentType: "application/json;odata=verbose",
data: JSON.stringify(
{
'__metadata': {
'type': 'SP.Data.ContactsListItem'
},
'Title': lname,
'FirstName': fname,
'WorkPhone': wphone
}),
headers: {
"accept": "application/json;odata=verbose",
"X-RequestDigest": $("#__REQUESTDIGEST").val(),
"IF-MATCH": "*",
"X-Http-Method": "PATCH"
},
success: function (data) {
REST.FormFiller.lock();
},
error: function (err) {
alert(JSON.stringify(err));
}
}
);
}