This is a migrated thread and some comments may be shown as answers.

Bad Request when POST/Updating Sharepoint List Item

1 Answer 109 Views
Data Source
This is a migrated thread and some comments may be shown as answers.
Christian
Top achievements
Rank 1
Christian asked on 23 Jul 2018, 07:10 AM

Hi,

 

I am trying to update Kendo Grid row inline, but getting a bad request when doing so. 

Reading from the list work just fine, but I am not able to update.

 

Any ideas?

var dataSource = new kendo.data.DataSource({
                transport: {
                    read: {
                        url: crudServiceBaseUrl + "?$top=2000",
                        type: "GET",
                        dataType: "json",
                        contentType: "application/json;odata=verbose",
                        headers: {
                            "accept": "application/json;odata=verbose"
                        }
                    },
                    // ...
                    update: {
                        url: function (data) {
                            return crudServiceBaseUrl + "(" + data.ID + ")";
                        },
                        type: "POST",
                        dataType: "json",
                        data: JSON.stringify({
                            "__metadata": { type: "SP.Data.MasterListItem" }
                        }),
                        contentType: "application/json;odata=verbose",
                        headers: {
                            "accept": "application/json;odata=verbose",
                            "X-RequestDigest": $("#__REQUESTDIGEST").val(),
                            "X-HTTP-Method": "MERGE"
                        },
                    },
                    //...
                    parameterMap: function (data, type) {
                        if (type == "update") {
                            for (var property in data) {
                                if (property != "__metadata")
                                    delete data[property];
                            }
                        }
                        return JSON.stringify(data);
                    }
                },
                error: function (e, data) {
                    console.log("Status: " + e.status + "; Error message: " + e.errorThrown );
                },
                pageSize: 15,
                schema: {
                    data: function (data) {
                        return data.d && data.d.results;
                    },
                    total: function (data) {
                        return data.d.results.length;
                    },
                    model: {
                        id: "Id",
                        fields: {
                            Id: { type: "number", editable: false, nullable: false },
                            Title: { type: "string", validation: { required: true } },
                            OWNER: { type: "string", validation: { required: false } }
                        }
                    }
                },
                //batch: false,
                //serverPaging: true,
                sort: { field: "OWNER", dir: "desc" }
            });

1 Answer, 1 is accepted

Sort by
0
Boyan Dimitrov
Telerik team
answered on 24 Jul 2018, 12:22 PM
Hello,

Could you please share what is the exact response of the update request and specifically the error stored in the response? This will help us determine what might be problem. Also if possible share the signature of the Update method in the controller. 

Regards,
Boyan Dimitrov
Progress Telerik
Try our brand new, jQuery-free Angular components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
Tags
Data Source
Asked by
Christian
Top achievements
Rank 1
Answers by
Boyan Dimitrov
Telerik team
Share this question
or