Skip to content

Instantly share code, notes, and snippets.

@vman
Last active July 7, 2023 14:49
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save vman/2f7b3b98c8041cc987ead19ba215852d to your computer and use it in GitHub Desktop.
Save vman/2f7b3b98c8041cc987ead19ba215852d to your computer and use it in GitHub Desktop.
Update SharePoint List items without using the '__metadata' property (ListItemEntityTypeFullName)
$(function() {
'use strict';
var requestHeaders = {
'X-RequestDigest': $("#__REQUESTDIGEST").val(),
"accept": "application/json;odata=nometadata",
"content-type": "application/json;odata=nometadata",
"IF-MATCH": "*",
"X-HTTP-Method":"MERGE"
};
var listItemData = {
'Title': "Updated without using '__metadata' property",
}
$.ajax({
url: _spPageContextInfo.webAbsoluteUrl + "/_api/lists/GetByTitle('MyCustomList')/items(1)",
type: "POST",
headers: requestHeaders,
data: JSON.stringify(listItemData),
success: function (data) {
console.log(data)
},
error: function (jqxr, errorCode, errorThrown) {
console.log(jqxr.responseText);
}
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment