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

Attempting to post data from scheduler to node API send GET request through transport method.

3 Answers 183 Views
Scheduler
This is a migrated thread and some comments may be shown as answers.
Andrew
Top achievements
Rank 1
Andrew asked on 11 Feb 2016, 09:58 PM

The only mention of POST method in the Scheduler documentation is in the section pertaining to PDF files.

I would like to make a POST request to save and update meetings. 

Currently, when I attempt to save an entry my Scheduler makes the following request:

GET http://ubnode/meeting?_id=56bcab3a2df7994c5a073201&created_by=andrewwimley&…dard+Time)&desc=asdf&mediator_LawyerIDs%5B%5D=475840&meeting_result=Manual 404 (Not Found)

 Also, is there any way to get rid of everything after the "?" ?

Here is my kendo scheduler constructor. Sorry that it is lengthy, but I'm not entirely sure which parts are relevant. 

 

$("#scheduler").kendoScheduler({
        date: new Date(),
        startTime: new Date(),
        height: 750,
        eventTemplate: $("#event-template").html(), //kendo.template(eventTemplateString), //$("#event-template").html(),
        editable: {
            template: $("#editorx").html()
        },
        add: scheduler_add,
        //editable: false,
        dataBound: function(e) {
            if (!dangLoad) {
                dangLoad = true;//wut? ok Brenden. DANGLOAD
 
                hideEvent();
            }
            //console.log(e);
            var scheduler = this;
            var view = scheduler.view();
 
            view.table.find("td[role=gridcell]").each(function() {
 
                var element = $(this);
                var slot = scheduler.slotByElement(element);
                if (slot.startDate < new Date) {
                    element.addClass("greyCell");
                }
 
            });
            $("#scheduler").kendoTooltip({
                filter: ".k-event",
                position: "top",
                width: 250,
                content: kendo.template($('#templatezz').html())
                    //content: "Tooltip content"
            });
        },
        change: function(e) {
 
            console.log("Changing.");
 
            if (user.role == "read-only") {
                console.log("You can not execute this action from a read-only account");
                e.preventDefault();
                return 1;
            }
 
            console.log('change');
            if (e.event.result == 'Manual') {} else {
                alert("cannot change " + e.event.case_name + " as it was created in Access");
                e.preventDefault();
            }
            //e.preventDefault();
            //console.log("Editing", e.event.title);
        },
        edit: function(e) {
            this.one("save", function () {
                console.log("saving: \n");
                console.log(e);
                e.preventDefault();
            });
 
            if (user.role == "read-only") {
                alert("You can not perform this action from a read-only account");
                e.preventDefault();
                showReadOnlyModal(e.event);
                return 1;
            }
 
            console.log(meds);
            console.log(e.event.created_by);
 
            //If role is mediator and created by mediator, its true
            //If role is cm and created by cm or admin, its true
 
            if (user.role == "mediator") {
                editRights = _.contains(meds, e.event.created_by);
            } else {
                editRights = !_.contains(meds, e.event.created_by); //Admins edit everything not created by a mediator.
            }
 
            console.log("edit rights: " + editRights);
 
            if (!editRights) {
                e.preventDefault();
                alert("You do not have the right to edit this entry.");
                return 1;
            }
 
            //Find in the mediator list the name of user, determine if created by is case manager or mediator
            //Use on get who creadted modified?
 
            console.log("editing");
 
            var addr, body, subject; //For automated emails.
                addr = "";
            console.log(e.event.mediatorIds);
            //subject = "A meeting scheduled for: " + e.event.start + " has been cancelled."
            //body = "This is an automated alert to let you know the meeting starting on: " + e.event.start + " has been changed by: " + user.name + ".";
 
            /*if (e.event.mediatorIds) {
                $.each(e.event.mediatorIds, function (k, v) {
                    console.log(v);
                    console.log(medMap);
 
                    //Finding the mediators...
                    var person = _.find( medMap, {"mediator_LawyerID": v});
                    addr += person.email;
                    addr += ";";
                    console.log(addr);
                });
            }*/
             
            if (e.event.result == 'Manual') {
                console.log(e.event);
                var getInfoPromise = getWhoCreatedModified(e.event.MeetingID);
                console.log(e.event.MeetingID);
                getInfoPromise.then(onGetWhoCreatedModifiedComplete, onErrorFunction);
 
            } else {
                showPartyInfoModal(e.event.parties, e.event.description, e.event.caseNumber, e.event);
                e.preventDefault();
            }
        },
 
        remove: function(e) {
            if (user.role == "read-only") {
                console.log("You can not execute this action from a read-only account");
                e.preventDefault();
                return 1;
            }
 
            if (e.event.result == 'Manual') {
                console.log("hey you try and remove");
                console.log(e);
                var meetingToDelete = e.event.MeetingID;
                var deleteEntryPromise = deleteEntry(meetingToDelete);
                deleteEntryPromise.then(onDeleteEntryComplete, onErrorFunction);
 
            } else {
                alert("cannot remove " + e.event.case_name + " as it was created in Access");
                e.preventDefault();
            }
            //e.preventDefault();
            //console.log("Editing", e.event.title);
        },
        //editable: editRights,
        views: [{
                    type: "day"
                }, {
                    type: "workWeek"
                }, {
                    type: "month",
                    selected: true,
                    eventHeight: 35
                }, {
                    type: "agenda"
                }
            /*, {
                                type: "timeline"
                            }, {
                                type: "timelineWorkWeek"
                            }, {
                                type: "timelineMonth"
                            }*/
        ],
        timezone: "US/Central",
        dataSource: {
            //data: scheduleDataz,
            transport: {
                read: {
                    //url: "getData.pl?ACTION=GETMEETINGS", //node rewrite
                    url: "/meetings",
                    dataType: "jsonp" // "jsonp" is required for cross-domain requests; use "json" for same-domain requests
                },
                update: {
                    url: "/meeting", //node rewrite
                    dataType: "jsonp"
                }
            },
            requestEnd: function(e) {
                //check the "response" argument to skip the local operations
                if (e.type === "read" && e.response) {
                    console.log("Current request is 'read'.");
                    console.log(e.response);
                }
              },
            schema: {
                model: {
                    id: "MeetingID",
                    fields: {
                        MeetingID: {
                            from: "meeting_id"
                        },
                        title: {
                            from: "case_name",
                            defaultValue: "No title",
                            validation: {
                                required: true
                            }
                        },
                        start: {
                            type: "date",
                            from: "start_time"
                        },
                        end: {
                            type: "date",
                            from: "end_time"
                        },
                        description: {
                            from: "desc"
                        },
                        caseManager: {
                            from: "case_manager",
                            nullable: true
                        },
                        mediatorIds: {
                            from: "mediator_LawyerIDs"
                        },
                        result: {
                            from: "meeting_result",
                            nullable: true
                        },
                        caseNumber: {
                            from: "case_number",
                            nullable: true
                        },
                        case_location: {
                            from: "location",
                            nullable: true
                        },
                        parties: {
                            from: "parties",
                            nullable: true
                        },
                        numParties: {
                            from: "number_of_parties",
                            nullable: true
                        },
                        created_by: {
                            from: "created_by",
                            nullable: true
                        },
                        creation_timestamp: {
                            from: "creation_timestamp",
                            nullable: true
                        },
 
                        //Recurrence specific fields
                        RecurrenceId: {
                            from: "RecurrenceId"
                        },
                        RecurrenceRule: {
                            from: "RecurrenceRule"
                        },
                        RecurrenceException: {
                            from: "RecurrenceException"
                        }                       
                    }
                }
            }
        },
        resources: [{
            field: "result",
            title: "Meeting Result",
            dataSource: [{
                text: "_",
                value: "Manual",
                color: "#661155"
            }, {
                text: "Canceled",
                value: "Canceled",
                color: "#CCCCCC"
            }, {
                text: "Settled",
                value: "Settled"
            }, {
                text: "Not settled",
                value: "Not settled"
            }, {
                text: "Settled Without Mediation",
                value: "Settled w/o Mediation"
            }]
        }, {
            field: "mediatorIds", // The field of the scheduler event which contains the resource identifier
            title: "Mediator", // The label displayed in the scheduler edit form for this resource
            dataSource: mediatorResources,
            multiple: true
        }]
    });

 

Thank you in advance.

3 Answers, 1 is accepted

Sort by
0
Andrew
Top achievements
Rank 1
answered on 12 Feb 2016, 03:59 PM

I got it to POST, unfortunately there is no data on the request body due to my parser being unable to handle this type of data:

 

_id=56bcab3a2df7994c5a073201&created_by=andrewwimley&case_desc=asdf&creation_timestamp=Thu+Feb+11+2016+09%3A39%3A38+GMT-0600+(CST)&date=Thu+Feb+11+2016+09%3A39%3A38+GMT-0600+(CST)&createdBy=andrewwimley&createDateTime=02%2F11%2F2016+09%3A39+am&endDateString=02-10-2016+11%3A59+pm&startDateString=02-10-2016+12%3A00+am&type=schedule_entry&__v=0&meeting_id=56bcab3a2df7994c5a073201&case_name=asdfffffff&start_time=Thu+Feb+11+2016+09%3A39%3A38+GMT-0600+(Central+Standard+Time)&end_time=Thu+Feb+11+2016+09%3A39%3A38+GMT-0600+(Central+Standard+Time)&desc=asdf&mediator_LawyerIDs%5B%5D=475840&meeting_result=Manual

This is my proxy's raw view.

I have dataType: json set in the scheduler constructor. This is obviously not JSON. How do I force this to JSON format, if not by using the dataType: json property?

0
Accepted
Vladimir Iliev
Telerik team
answered on 15 Feb 2016, 11:57 AM
Hello Andrew,

Please check the sample configuration below of posting the data as "JSON":

create: {
    url: "/Home/Meetings_Create",
    dataType: "json",
    contentType: "application/json",
    type: "POST"
},
parameterMap: function (data, operation) {
    return JSON.stringify(data);
}

Regards,
Vladimir Iliev
Telerik
 
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
 
0
Andrew
Top achievements
Rank 1
answered on 15 Feb 2016, 07:46 PM
Indeed I was missing the fact that parameterMap is necessary to send data as JSON. 
Tags
Scheduler
Asked by
Andrew
Top achievements
Rank 1
Answers by
Andrew
Top achievements
Rank 1
Vladimir Iliev
Telerik team
Share this question
or