Monday, February 1, 2016

Rest Api Update Items

                $.ajax({
                    url: _spPageContextInfo.webAbsoluteUrl + "/_api/web/lists/GetByTitle('Projects')/GetItemById('" + Folder + "')",
                    type: "POST",
                    data: JSON.stringify({
         '__metadata': { 'type': 'SP.Data.ProjectsListItem' },//ProjectsListItem where Projects is list name
                        '{0}': "No"
                    }).replace("{0}", FieldName),
                    contentType: 'application/json;odata=verbose',
                    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 (err) {
                        console.log("Error while updating item: " + JSON.stringify(err));
                    }

                });

No comments:

Post a Comment