View Full Version : Reader and accept header

7 Jan 2011, 6:31 AM
Hi. I have an RestProxy with a reader and a writer with type JSON. I send in a POST request to my Java backend (Jersey) but I get XML instead of JSON back. When testing this in Firefox Poster I get XML back, but if I set the additional header "accept" to "application/json", then the backend returns JSON like I'm looking for.

So my question is, how can I add this header in my RestProxy request and is this default behavior so it should be included in sencha?

28 Jun 2011, 1:13 AM
can I know how Accept header was added?
becouse I have same problem, but I cannot decide by using Accept header :-(

I try so:

proxy : {
headers : {
'Content-type' : 'application/json',
'accept': 'application/json'

28 Jun 2011, 2:59 AM
It was very long time since I wrote this, so can't say for sure how I solved it. But I searched my old code and found no trace of "accept" in my js code. I'm guessing the problem might have been that I forgot the @Produces("application/json") in my Jersey project.

29 Jun 2011, 10:25 AM
Extract from: http://www.sencha.com/forum/showthread.php?118403-Default-headers-Ajax-request-not-used

Ext.Ajax.defaultHeaders = {
'Accept' : 'application/json,application/xml',
'Content-Type' : 'application/json'
};I tested and it's working. Of course, since ExtJS provide already lot of tuning for proxy/reader/writer it should allow to specify this for each proxy, and maybe guess the type from the reader.

26 Aug 2011, 12:21 PM
In sencha Touch:

setting the header attribute in the proxy config doesn't work

the work around to have Ext.Ajax.defaultHeaders does work though.

is this a bug or am i missing something