1

I know that updating an item in sharepoint list by using REST API should be very easy, but for some reason, I have not been able to do it. I keep getting "400 Bad Request: The property __deferred does not exist on type SP.SecurableObject error, and I do not know, nor understand, why is that happening. I'm sure this has to be something easy to fix, but I'm a complete newbie in javascript (and in general to everything related to web developing). I have tried some approaches that I find throughout the web, but I was not able to solve this issue.

This is the code that I'm using:

function UpdateItem(ListName, ItemID, ItemData) {

    return $.ajax({
        method: "POST",
        data: JSON.stringify(ItemData),
        headers: {
            "Accept": "application/json;odata=verbose",
            "X-RequestDigest": $("#__REQUESTDIGEST").val(),
            "X-HTTP-Method": "MERGE",
            "If-Match": ItemData.__metadata.etag,
            "content-type": "application/json;odata=verbose",
        },
        url: ItemData.__metadata.uri,
        success: function () {
            console.log("Item Updated");
        },
        error: function (msgError) {
            console.log("Error");
        }
    });
}

And I'm making use of that function this way:

GetItem(ListName, ItemId).done(function(data){
    var oldItem = data.d;
    oldItem.Title = "Modified Title";
    UpdateItem(ListName, ItemId, oldItem).done(function (data) {
        console.log("Item Updated", data);
    });
});

I'm able to perform an update using jsom, but I want to do it by using REST API.

Could you guys please help me to solve (or/and understand why?) this?

Thaks in advance.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.