Skip to main content

Search

HTTP Request - Create List Item

Comments

2 comments

  • Kilgore ServiceAccount

    The same behavior happens with an Update Item HTTP Request as well...

    Am I missing something with Authorization? or a Token?

     

    Thanks

    0
  • Kilgore ServiceAccount

    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.