0

Hi,

I am a newbie to Backbone, My Rest Server Components Accept Only XML Requests, can Anybody show an example how do i send a xml to a rest api put request.

Community
  • 1
  • 1
Vinay
  • 15
  • 6

1 Answers1

0

Backbone uses JSON by default, so to use XML you need to overwrite Backbone.sync. Take a look at this answer: How to override Backbone.sync?

Community
  • 1
  • 1
David Sulc
  • 25,946
  • 3
  • 52
  • 54
  • I did change the options.contentType="application/xml" but still the requestheader contentType is application/json. If somebody can show me an example of sending a xml as a payload that will be very helpful. – Vinay Mar 12 '14 at 12:38
  • The option you should be using is `dataType`, not `contentType`. See https://api.jquery.com/jQuery.ajax/ – David Sulc Mar 12 '14 at 13:13
  • I have set dataType also as xml; – Vinay Mar 13 '14 at 05:13
  • I need to send xml as a payload, anybody please help with an example. – Vinay Mar 13 '14 at 09:33
  • Oops, sorry: to *send* XML you need to define the `contentType` attribute for the jQuery `$.ajax` call. Once you've serialized your data as XAML in the function call to `ajax` it should send the data as XML correctly. Also, check whether you need to add ".xml" to your url. – David Sulc Mar 13 '14 at 09:59
  • can anybody help me with an example :-( – Vinay Mar 14 '14 at 09:34