HTTP Request - Create List Item
Greetings,
I am looking for help with a basic HTTP Request to create a list item. I keep getting a security error. I am sure I am doing some very simple, wrong.
odata=nometadata
Thanks,
Taylor
0
-
The same behavior happens with an Update Item HTTP Request as well...
Am I missing something with Authorization? or a Token?
Thanks
0 -
I am able to accomplish the exact same with AJAX, but I cannot use Execute Script in Triggered Actions. I am not understanding why the exact same HTTP Request is having issues.
var listName = [[@List.Title]];
var webUrl = [[@Web.Url]];
var itemId = [[ID]];
var itemData = {
"__metadata": { "type": "SP.Data." + listName + "ListItem" },
"TeamsTabsCreated": "Start",
"MembersAddedToTeam": "Start"
};
$.ajax({
url: webUrl + "/_api/web/lists/getbytitle('" + listName + "')/items(" + itemId + ")",
type: "POST",
contentType: "application/json;odata=verbose",
data: JSON.stringify(itemData),
headers: {
"Accept": "application/json;odata=verbose",
"X-RequestDigest": $("#__REQUESTDIGEST").val(),
"X-HTTP-Method": "MERGE",
"If-Match": "*"
},
success: function (data) {
console.log("Item updated successfully");
},
error: function (error) {
console.log(JSON.stringify(error));
}
});0
Please sign in to leave a comment.
Comments
2 comments