Read datasource - Post array of strings to Web API

2 posts, 1 answers
  1. Jakub
    Jakub avatar
    5 posts
    Member since:
    Apr 2014

    Posted 27 Apr 2014 Link to this post

    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.
  2. Answer
    Alexander Popov
    Admin
    Alexander Popov avatar
    1416 posts

    Posted 29 Apr 2014 Link to this post

    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!
     
  3. Kendo UI is VS 2017 Ready
Back to Top