Hello -
This is an offshoot of: http://www.telerik.com/forums/problem-with-datasource-post-request-for-read-operation
Unfortunately, that thread is closed so I can't follow-up.
However, it seems to me that there's a potential bug with DataSource (used inside a Kendo Grid) when doing a READ using POST and contentType = "application/json".
Here is my javascript:
However, based on examining the network traffic, here's the POST request information:
You can see in that very last line, the paging parameters for the Grid are being sent as key/value pairs (URL param encoding) instead of JSON.
I would think that since I'm setting contentType to JSON, and using a POST, that internally the DataSource would JSON encode my paging parameters.
The workaround (based on info in the link above) is to override the parameterMap function:
This creates JSON in the Request Payload:
But it seems to me I shouldn't need to override parameterMap if I'm telling the datasource to use application/json.
My only guess is that Kendo is just passing the contentType to the internal AJAX call to set the POST header and not actually doing anything with that information (like converting the URL/form encoded parameters to JSON).
This is an offshoot of: http://www.telerik.com/forums/problem-with-datasource-post-request-for-read-operation
Unfortunately, that thread is closed so I can't follow-up.
However, it seems to me that there's a potential bug with DataSource (used inside a Kendo Grid) when doing a READ using POST and contentType = "application/json".
Here is my javascript:
dataSource: {
transport: {
read: {
url:
"rest/books"
,
type:
"POST"
,
contentType:
"application/json; charset=utf-8"
}
...
However, based on examining the network traffic, here's the POST request information:
Remote Address:[::1]:8082
Request URL:rest/books
Request Method:POST
Status Code:400 Bad Request
Request Headersview source
Accept:*/*
Accept-Encoding:gzip, deflate
Accept-Language:en-US,en;q=0.8
Cache-Control:no-cache
Connection:keep-alive
Content-Length:31
Content-Type:application/json; charset=UTF-8
Host:localhost:8082
Origin:http://localhost:8081
Pragma:no-cache
Referer:http://localhost:8081/
User-Agent:Mozilla/5.0 (Macintosh; Intel Mac OS X 10_9_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/40.0.2214.91 Safari/537.36
Request Payload
take=5&skip=0&page=1&pageSize=5
You can see in that very last line, the paging parameters for the Grid are being sent as key/value pairs (URL param encoding) instead of JSON.
I would think that since I'm setting contentType to JSON, and using a POST, that internally the DataSource would JSON encode my paging parameters.
The workaround (based on info in the link above) is to override the parameterMap function:
parameterMap:
function
(options) {
return
JSON.stringify(options);
}
This creates JSON in the Request Payload:
{
"take"
:5,
"skip"
:0,
"page"
:1,
"pageSize"
:5}
But it seems to me I shouldn't need to override parameterMap if I'm telling the datasource to use application/json.
My only guess is that Kendo is just passing the contentType to the internal AJAX call to set the POST header and not actually doing anything with that information (like converting the URL/form encoded parameters to JSON).