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

Read datasource - Post array of strings to Web API

1 Answer 162 Views
Scheduler
This is a migrated thread and some comments may be shown as answers.
Jakub
Top achievements
Rank 2
Jakub asked on 27 Apr 2014, 09:42 PM
Hello

I am trying to accomplish following, get appointments of a user through POST request as I need to post other calendar ids to get appointments of other users as well. The POST request is sent to a Web API. The endpoint gets hit but the array of calendarIds is always empty.

This is the datasource definition:

dataSource: new kendo.data.SchedulerDataSource({
batch: true,
transport: {
read: {
url: "/api/MyCalendar/GetAppointments",
dataType: "json",
type: "POST"
},
parameterMap: function(data, type) {
if (type === "read") {
return JSON.stringify(data);
}
}
}

This is the Web API implementation:

[HttpPost]
public HttpResponseMessage GetAppointments(string[] calendarIds)
{

// calendarIds is always empty

This the request posted content (textView) from fiddler:{"calendarIds":["1c78e75f-9516-42cf-a439-271ee997abf1"]}

I am not sure what is wrong in here, thanks for any help on this.

1 Answer, 1 is accepted

Sort by
0
Accepted
Alexander Popov
Telerik team
answered on 29 Apr 2014, 03:17 PM
Hi Jakub,

Try enabling the traditional serialization option, for example: 
read: {
    url: "/api/MyCalendar/GetAppointments",
    dataType: "json",
    type: "POST"
    traditional: true,
},
...
parameterMap: function(data, type) {
    if (type === "read") {
        return data;
    }
}


Regards,
Alexander Popov
Telerik
 
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
 
Tags
Scheduler
Asked by
Jakub
Top achievements
Rank 2
Answers by
Alexander Popov
Telerik team
Share this question
or