You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@couchdb.apache.org by wh...@aol.com on 2010/08/12 09:07:55 UTC

couchdb and extjs problems accepting json

 I'm querying couchdb as a view which returns a json response. I cut the json view out and pasted it into xtest.json.

I have written a script using extjs that will accept this file and correctly fill up an extjs grid.
To get this to work I give the extjs  the url  xtest.json and it works fine.

If I give instead give it the couchdb view link which returns the exact same thing -- it does not work at all.

Can someone explain why one works and the other does not.  The forum members on extjs are stumped.
We examined the XHR response and header and it's exactly the same as getting the xtest.json file.
Is there an extjs guru around who could explain why it's not working?

Thanks,

Dan



Re: couchdb and extjs problems accepting json

Posted by Aurélien Bénel <au...@utt.fr>.
>> I just noticed (on CouchDB 1.0.0) that views return "Content-Type: text/plain;charset=utf-8"... even when "Content-Type: application/json" was in the GET request.
> This is only true if you don't set the correct accept header:
> curl -v -H "Accept: application/json" http://localhost:5984/test/_design/foo/_view/bar

True. Sorry. I suppose the REST client I use has a buggy cache.


Regards,

Aurélien

Re: couchdb and extjs problems accepting json

Posted by Sebastian Cohnen <se...@googlemail.com>.
This is only true if you don't set the correct accept header:

curl -v -H "Accept: application/json" http://localhost:5984/test/_design/foo/_view/bar
> GET /test/_design/foo/_view/bar HTTP/1.1
> User-Agent: curl/7.19.7 (universal-apple-darwin10.0) libcurl/7.19.7 OpenSSL/0.9.8l zlib/1.2.3
> Host: localhost:5984
> Accept: application/json
> 
< HTTP/1.1 200 OK
< Transfer-Encoding: chunked
< Server: CouchDB/1.0.0 (Erlang OTP/R13B)
< Etag: "D2TAVA3VM8AN5VR54PD3HDDM5"
< Date: Thu, 12 Aug 2010 07:28:02 GMT
< Content-Type: application/json
< Cache-Control: must-revalidate
< 
....

On 12.08.2010, at 09:21, Aurélien Bénel wrote:

> Hi Whimsica,
> 
>> If I give instead give it the couchdb view link which returns the exact same thing -- it does not work at all.
> 
> 
> I just noticed (on CouchDB 1.0.0) that views return "Content-Type: text/plain;charset=utf-8"... even when "Content-Type: application/json" was in the GET request.
> 
> Couldn't it be the reason why extjs is confused?
> 
> 
> Regards,
> 
> Aurélien


Re: couchdb and extjs problems accepting json

Posted by J Chris Anderson <jc...@apache.org>.
On Aug 12, 2010, at 9:20 AM, whimsica@aol.com wrote:

> 405 Method not allowed is the problem
> 
> I'm now using firebug and tracking the NET responses.
> 
> when the extjs calls
> http://localhost:5984/wikiha/_design/view1/_view/myview.json

This URL isn't proper.

The Couch View will be at

http://localhost:5984/wikiha/_design/view1/_view/myview

eg without the .json suffix.

Maybe that is part of it.

What verb did you use to get the 405? It seems you should have gotten a 404 but maybe there is another thing happening.

Chris

> it gives back a 405 method not allowed error.
> 
> What does that mean
> 
> 
> 
> 
> 
> 
> 
> 
> -----Original Message-----
> From: whimsica@aol.com
> To: user@couchdb.apache.org
> Sent: Thu, Aug 12, 2010 8:31 am
> Subject: Re: couchdb and extjs problems accepting json
> 
> 
> I don't know if that's the right thing but I'm asking on the extjs forum.
> It seems it would be easier to force couchdb to force send application/json for the view query?
> Is there any way to do that?
> 
> Thanks,
> 
> Dan
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> -----Original Message-----
> From: Aurélien Bénel <au...@utt.fr>
> To: user@couchdb.apache.org
> Sent: Thu, Aug 12, 2010 1:31 am
> Subject: Re: couchdb and extjs problems accepting json
> 
> 
>> I don't know how to send anything along with that.
> 
> 
> 
> 
> 
>> Can you tell me what needs to be done/fixed?
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> It would probably better to ask the extjs community about how to add headers... 
> 
> 
> 
> 
> 
> But it seems that your answer is here:
> 
> 
> 
> 
> 
> http://dev.sencha.com/deploy/ext/docs/output/Ext.Ajax.html (search the page for 
> 
> 
> 
> 
> 
> "headers").
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> Regards,
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> Aurélien =
> 
> 
> 
> 
> 
> 
> 
> 


Re: couchdb and extjs problems accepting json

Posted by James Hayton <th...@purplebulldog.com>.
Try running extjs script served up by couch.  You have extjs not running on same port as couch if I remember correctly.  Other option is the proxy extjs offers.  

Sent Via iPhone

On Aug 12, 2010, at 9:20 AM, whimsica@aol.com wrote:

> 405 Method not allowed is the problem
> 
> I'm now using firebug and tracking the NET responses.
> 
> when the extjs calls
> http://localhost:5984/wikiha/_design/view1/_view/myview.json
> it gives back a 405 method not allowed error.
> 
> What does that mean
> 
> 
> 
> 
> 
> 
> 
> 
> -----Original Message-----
> From: whimsica@aol.com
> To: user@couchdb.apache.org
> Sent: Thu, Aug 12, 2010 8:31 am
> Subject: Re: couchdb and extjs problems accepting json
> 
> 
> I don't know if that's the right thing but I'm asking on the extjs forum.
> It seems it would be easier to force couchdb to force send application/json for the view query?
> Is there any way to do that?
> 
> Thanks,
> 
> Dan
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> -----Original Message-----
> From: Aurélien Bénel <au...@utt.fr>
> To: user@couchdb.apache.org
> Sent: Thu, Aug 12, 2010 1:31 am
> Subject: Re: couchdb and extjs problems accepting json
> 
> 
>> I don't know how to send anything along with that.
> 
> 
> 
> 
> 
>> Can you tell me what needs to be done/fixed?
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> It would probably better to ask the extjs community about how to add headers... 
> 
> 
> 
> 
> 
> But it seems that your answer is here:
> 
> 
> 
> 
> 
> http://dev.sencha.com/deploy/ext/docs/output/Ext.Ajax.html (search the page for 
> 
> 
> 
> 
> 
> "headers").
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> Regards,
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> Aurélien =
> 
> 
> 
> 
> 
> 
> 
> 

Re: couchdb and extjs problems accepting json

Posted by wh...@aol.com.
405 Method not allowed is the problem

I'm now using firebug and tracking the NET responses.

when the extjs calls
http://localhost:5984/wikiha/_design/view1/_view/myview.json
it gives back a 405 method not allowed error.

What does that mean

 


 

 

-----Original Message-----
From: whimsica@aol.com
To: user@couchdb.apache.org
Sent: Thu, Aug 12, 2010 8:31 am
Subject: Re: couchdb and extjs problems accepting json


I don't know if that's the right thing but I'm asking on the extjs forum.
It seems it would be easier to force couchdb to force send application/json for the view query?
Is there any way to do that?

Thanks,

Dan

 

 


 

 

-----Original Message-----
From: Aurélien Bénel <au...@utt.fr>
To: user@couchdb.apache.org
Sent: Thu, Aug 12, 2010 1:31 am
Subject: Re: couchdb and extjs problems accepting json


> I don't know how to send anything along with that.





> Can you tell me what needs to be done/fixed?











It would probably better to ask the extjs community about how to add headers... 





But it seems that your answer is here:





http://dev.sencha.com/deploy/ext/docs/output/Ext.Ajax.html (search the page for 





"headers").

















Regards,











Aurélien =






 
 

Re: couchdb and extjs problems accepting json

Posted by wh...@aol.com.
I don't know if that's the right thing but I'm asking on the extjs forum.
It seems it would be easier to force couchdb to force send application/json for the view query?
Is there any way to do that?

Thanks,

Dan

 

 


 

 

-----Original Message-----
From: Aurélien Bénel <au...@utt.fr>
To: user@couchdb.apache.org
Sent: Thu, Aug 12, 2010 1:31 am
Subject: Re: couchdb and extjs problems accepting json


> I don't know how to send anything along with that.

> Can you tell me what needs to be done/fixed?



It would probably better to ask the extjs community about how to add headers... 

But it seems that your answer is here:

http://dev.sencha.com/deploy/ext/docs/output/Ext.Ajax.html (search the page for 

"headers").





Regards,



Aurélien =


 

Re: couchdb and extjs problems accepting json

Posted by Aurélien Bénel <au...@utt.fr>.
> I don't know how to send anything along with that.
> Can you tell me what needs to be done/fixed?

It would probably better to ask the extjs community about how to add headers... But it seems that your answer is here:
http://dev.sencha.com/deploy/ext/docs/output/Ext.Ajax.html (search the page for "headers").


Regards,

Aurélien 

Re: couchdb and extjs problems accepting json

Posted by wh...@aol.com.
How would I do that? The extjs code just specifies a url for retrieving the JSON info.
I don't know how to send anything along with that.

Can you tell me what needs to be done/fixed?

Thanks,

Dan


 

 


 

 

-----Original Message-----
From: Sebastian Cohnen <se...@googlemail.com>
To: user@couchdb.apache.org
Sent: Thu, Aug 12, 2010 1:13 am
Subject: Re: couchdb and extjs problems accepting json


yes, you need to send Accept: application/json to tell couchdb to return 

Content-Type: application/json. Maybe that's the issue that causes trouble with 

extjs (although I hardly know extjs and I'm just guessing here)



On 12.08.2010, at 10:07, whimsica@aol.com wrote:



> upon querying a view I get the following

> 

> The response is

> {"total_rows":3,"offset":0,"rows":[

> {"id":"biking","key":"Biking","value":"My biggest hobby is mountainbiking. The 

other day..."},

> {"id":"bought-a-cat","key":"Bought a Cat","value":"I went to the the pet store 

earlier and brought home a little kitty..."},

> {"id":"hello-world","key":"Hello World","value":"Well hello and welcome to my 

new blog..."}

> ]}

> 

> 

> The header is

> Hostlocalhost:5984User-AgentMozilla/5.0 (X11; U; Linux x86_64; en-US; 

rv:1.9.2.8) Gecko/20100723 Ubuntu/10.04 (lucid) Firefox/3.6.8Accepttext/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8Accept-Languageen-us,en;q=0.5Accept-Encodinggzip,deflateAccept-CharsetISO-8859-1,utf-8;q=0.7,*;q=0.7Keep-Alive115Connectionkeep-aliveIf-None-Match"4FJLAY9EA3N0KM3J06ZGFPAK9"

> 

> 

> 

> Does that help?

> 

> 

> Thanks,

> Dan

> 

> 

> 

> -----Original Message-----

> From: Nils Breunese <N....@vpro.nl>

> To: user@couchdb.apache.org <us...@couchdb.apache.org>

> Sent: Thu, Aug 12, 2010 12:51 am

> Subject: Re: couchdb and extjs problems accepting json

> 

> 

> Aurélien Bénel wrote:

> 

> 

> 

>> I just noticed (on CouchDB 1.0.0) that views return "Content-Type: 

> 

> text/plain;charset=utf-8"... even when "Content-Type: application/json" was in 



> 

> the GET request.

> 

> 

> 

> You should set "Accept: application/json" on your GET request, not 

> 

> "Content-Type: application/json".

> 

> 

> 

> Nils.

> 

> 

> 

> De informatie vervat in deze  e-mail en meegezonden bijlagen is uitsluitend 

> 

> bedoeld voor gebruik door de geadresseerde en kan vertrouwelijke informatie 

> 

> bevatten. Openbaarmaking, vermenigvuldiging, verspreiding en/of verstrekking 

van 

> 

> deze informatie aan derden is voorbehouden aan geadresseerde. De VPRO staat 

niet 

> 

> in voor de juiste en volledige overbrenging van de inhoud van een verzonden 

> 

> e-mail, noch voor tijdige ontvangst daarvan.

> 

> 

> 


 

Re: couchdb and extjs problems accepting json

Posted by Sebastian Cohnen <se...@googlemail.com>.
yes, you need to send Accept: application/json to tell couchdb to return Content-Type: application/json. Maybe that's the issue that causes trouble with extjs (although I hardly know extjs and I'm just guessing here)

On 12.08.2010, at 10:07, whimsica@aol.com wrote:

> upon querying a view I get the following
> 
> The response is
> {"total_rows":3,"offset":0,"rows":[
> {"id":"biking","key":"Biking","value":"My biggest hobby is mountainbiking. The other day..."},
> {"id":"bought-a-cat","key":"Bought a Cat","value":"I went to the the pet store earlier and brought home a little kitty..."},
> {"id":"hello-world","key":"Hello World","value":"Well hello and welcome to my new blog..."}
> ]}
> 
> 
> The header is
> Hostlocalhost:5984User-AgentMozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.8) Gecko/20100723 Ubuntu/10.04 (lucid) Firefox/3.6.8Accepttext/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8Accept-Languageen-us,en;q=0.5Accept-Encodinggzip,deflateAccept-CharsetISO-8859-1,utf-8;q=0.7,*;q=0.7Keep-Alive115Connectionkeep-aliveIf-None-Match"4FJLAY9EA3N0KM3J06ZGFPAK9"
> 
> 
> 
> Does that help?
> 
> 
> Thanks,
> Dan
> 
> 
> 
> -----Original Message-----
> From: Nils Breunese <N....@vpro.nl>
> To: user@couchdb.apache.org <us...@couchdb.apache.org>
> Sent: Thu, Aug 12, 2010 12:51 am
> Subject: Re: couchdb and extjs problems accepting json
> 
> 
> Aurélien Bénel wrote:
> 
> 
> 
>> I just noticed (on CouchDB 1.0.0) that views return "Content-Type: 
> 
> text/plain;charset=utf-8"... even when "Content-Type: application/json" was in 
> 
> the GET request.
> 
> 
> 
> You should set "Accept: application/json" on your GET request, not 
> 
> "Content-Type: application/json".
> 
> 
> 
> Nils.
> 
> 
> 
> De informatie vervat in deze  e-mail en meegezonden bijlagen is uitsluitend 
> 
> bedoeld voor gebruik door de geadresseerde en kan vertrouwelijke informatie 
> 
> bevatten. Openbaarmaking, vermenigvuldiging, verspreiding en/of verstrekking van 
> 
> deze informatie aan derden is voorbehouden aan geadresseerde. De VPRO staat niet 
> 
> in voor de juiste en volledige overbrenging van de inhoud van een verzonden 
> 
> e-mail, noch voor tijdige ontvangst daarvan.
> 
> 
> 


Re: couchdb and extjs problems accepting json

Posted by wh...@aol.com.
upon querying a view I get the following

The response is
 {"total_rows":3,"offset":0,"rows":[
{"id":"biking","key":"Biking","value":"My biggest hobby is mountainbiking. The other day..."},
{"id":"bought-a-cat","key":"Bought a Cat","value":"I went to the the pet store earlier and brought home a little kitty..."},
{"id":"hello-world","key":"Hello World","value":"Well hello and welcome to my new blog..."}
]}


The header is
Hostlocalhost:5984User-AgentMozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.8) Gecko/20100723 Ubuntu/10.04 (lucid) Firefox/3.6.8Accepttext/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8Accept-Languageen-us,en;q=0.5Accept-Encodinggzip,deflateAccept-CharsetISO-8859-1,utf-8;q=0.7,*;q=0.7Keep-Alive115Connectionkeep-aliveIf-None-Match"4FJLAY9EA3N0KM3J06ZGFPAK9"

 

Does that help?


Thanks,
Dan

 

-----Original Message-----
From: Nils Breunese <N....@vpro.nl>
To: user@couchdb.apache.org <us...@couchdb.apache.org>
Sent: Thu, Aug 12, 2010 12:51 am
Subject: Re: couchdb and extjs problems accepting json


Aurélien Bénel wrote:



> I just noticed (on CouchDB 1.0.0) that views return "Content-Type: 

text/plain;charset=utf-8"... even when "Content-Type: application/json" was in 

the GET request.



You should set "Accept: application/json" on your GET request, not 

"Content-Type: application/json".



Nils.



De informatie vervat in deze  e-mail en meegezonden bijlagen is uitsluitend 

bedoeld voor gebruik door de geadresseerde en kan vertrouwelijke informatie 

bevatten. Openbaarmaking, vermenigvuldiging, verspreiding en/of verstrekking van 

deze informatie aan derden is voorbehouden aan geadresseerde. De VPRO staat niet 

in voor de juiste en volledige overbrenging van de inhoud van een verzonden 

e-mail, noch voor tijdige ontvangst daarvan.


 

Re: couchdb and extjs problems accepting json

Posted by Nils Breunese <N....@vpro.nl>.
Aurélien Bénel wrote:

> I just noticed (on CouchDB 1.0.0) that views return "Content-Type: text/plain;charset=utf-8"... even when "Content-Type: application/json" was in the GET request.

You should set "Accept: application/json" on your GET request, not "Content-Type: application/json".

Nils.

De informatie vervat in deze  e-mail en meegezonden bijlagen is uitsluitend bedoeld voor gebruik door de geadresseerde en kan vertrouwelijke informatie bevatten. Openbaarmaking, vermenigvuldiging, verspreiding en/of verstrekking van deze informatie aan derden is voorbehouden aan geadresseerde. De VPRO staat niet in voor de juiste en volledige overbrenging van de inhoud van een verzonden e-mail, noch voor tijdige ontvangst daarvan.

Re: couchdb and extjs problems accepting json

Posted by Aurélien Bénel <au...@utt.fr>.
Hi Whimsica,

> If I give instead give it the couchdb view link which returns the exact same thing -- it does not work at all.


I just noticed (on CouchDB 1.0.0) that views return "Content-Type: text/plain;charset=utf-8"... even when "Content-Type: application/json" was in the GET request.
 
Couldn't it be the reason why extjs is confused?


Regards,

Aurélien