Post with xml data to Rest web service

3 posts, 1 answers
  1. Jeff Sager
    Jeff Sager avatar
    26 posts
    Member since:
    Aug 2006

    Posted 01 May 2012 Link to this post

    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. Answer
    Alexander Valchev
    Admin
    Alexander Valchev avatar
    2875 posts

    Posted 04 May 2012 Link to this post

    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!
  3. Kendo UI is VS 2017 Ready
  4. Jonathan
    Jonathan avatar
    10 posts
    Member since:
    Jun 2012

    Posted 18 Jul 2012 Link to this post

    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
    	}
    } 


Back to Top