Hi,
I'm trying to post pure json data this way:
create: {
url: crudServiceBaseUrl,
dataType: "jsonp",
contentType: "application/json",
type: "POST"
},
parameterMap: function (options, operation) {
if (operation !== "read" && options) {
return { models: kendo.stringify(options) };
}
}
}
batch:false
(I use 'options' instead of 'options.models' since I'm not using batch post)
but the post is not formatted correctly. If I look at the request payload (in chrome dev tools) it says
models=%7B%22Id%22%3Anull%2C%22Content%22%3A%22somecontent%22%2C%22Order%22%3A0%2C%22Done%22%3Afalse%7D
which the server does not like and responds with 400 bad request
however, if I add my own jQuery.ajax function like this:
$.ajax({
type: 'POST',
url: '/api/todos',
data: kendo.stringify(options),
contentType: 'application/json',
dataType: 'jsonp',
success: function (data) {
_resData = data;
},
async: false
});
the request is ok:
{"Id":null,"Content":"somecontent","Order":0,"Done":false}
and the server responds OK
What am I doing wrong?
Thanks
I'm trying to post pure json data this way:
create: {
url: crudServiceBaseUrl,
dataType: "jsonp",
contentType: "application/json",
type: "POST"
},
parameterMap: function (options, operation) {
if (operation !== "read" && options) {
return { models: kendo.stringify(options) };
}
}
}
batch:false
(I use 'options' instead of 'options.models' since I'm not using batch post)
models=%7B%22Id%22%3Anull%2C%22Content%22%3A%22somecontent%22%2C%22Order%22%3A0%2C%22Done%22%3Afalse%7D
which the server does not like and responds with 400 bad request
however, if I add my own jQuery.ajax function like this:
$.ajax({
type: 'POST',
url: '/api/todos',
data: kendo.stringify(options),
contentType: 'application/json',
dataType: 'jsonp',
success: function (data) {
_resData = data;
},
async: false
});
{"Id":null,"Content":"somecontent","Order":0,"Done":false}
and the server responds OK
What am I doing wrong?
Thanks