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

Post with xml data to Rest web service

2 Answers 146 Views
Data Source
This is a migrated thread and some comments may be shown as answers.
Jeff
Top achievements
Rank 2
Jeff asked on 01 May 2012, 07:35 PM
I am trying to set up a datasource with the code at the end of the post but the data isn't sent to the server (xmlstring is a string of the xml to be included as the body)  I always get content length zero.
Is it possible to send an xml string as the body of a POST?  I do this from desktop applications and Flash (actionscript) in a similar way but can't seem to get any results with Kendo.  Any help would be appreciated.  

As am FYI this works but I'm guessing I can't do this with the Kendo datasource (  $.ajax({
				    type: 'POST',
				    url: "http://rest.site.comm/rest/isc/packagecontents",
				    data: xmlstring,
				    dataType: "xml")

Thanks,
Jeff

  var dataSource = new kendo.data.DataSource({
                        transport: {
                        read: {
                        type: "POST",
                            // specify the XML file to read. The same as read: { url: "books.xml" }
                          url: "http:/rest.site.com/rest/isc/packagecontents/" ,   
                            dataType: "xml", 
                           data: xmlstring
                        } 

2 Answers, 1 is accepted

Sort by
0
Accepted
Alexander Valchev
Telerik team
answered on 04 May 2012, 03:26 PM
Hello Jeff,

The dataSource transport uses same configuration options as jQuery.ajax() method, so you should be able to send additional data.
Please check the following example:
transport: {
    read: {
        url: "../../content/web/datasource/books.xml",
        dataType: "xml",
        type: "POST",
        data: { testxml: escape('<test></test>')}
    }
}


Regards,
Alexander Valchev
the Telerik team
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
Jonathan
Top achievements
Rank 1
answered on 18 Jul 2012, 05:19 PM
Hi Jeff,

You probably solved this already, but in case someone else is looking for an answer...  Based on Alexanders response I think the following should probably work:

transport: {
	read: {
        	type: "POST",
	        // specify the XML file to read. The same as read: { url: "books.xml" }
	        url: "http:/rest.site.com/rest/isc/packagecontents/" ,   
	        dataType: "xml"		// this will tell jquery to leave the payload alone
		processData: false,
		data: xmlstring
	}
} 


Tags
Data Source
Asked by
Jeff
Top achievements
Rank 2
Answers by
Alexander Valchev
Telerik team
Jonathan
Top achievements
Rank 1
Share this question
or