You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@couchdb.apache.org by Debasish Ghosh <gh...@gmail.com> on 2009/04/23 10:23:09 UTC
problem with temp view
Hi -
I have been facing a problem with temp view creation from command line. When
I try ..
$ curl -vX POST -H "Content-Type: application/json" -d '{"map" :
"function(doc) { emit(null, doc) }"}'
http://localhost:5984/hello-world/_tmp_view
the error that I get is the following ..
{"error":"bad_content_type","reason":"Invalid Content-Type header for form
upload"}
The following is the complete response that I get ..
$ curl -vX POST -H "Content-Type: application/json" -d '{"map" :
"function(doc) { emit(null, doc) }"}'
http://localhost:5984/hello-world/_tmp_view
* About to connect() to localhost port 5984 (#0)
* Trying 127.0.0.1... connected
* Connected to localhost (127.0.0.1) port 5984 (#0)
> POST /hello-world/_tmp_view HTTP/1.1
> User-Agent: curl/7.18.0 (i486-pc-linux-gnu) libcurl/7.18.0 OpenSSL/0.9.8g
zlib/1.2.3.3 libidn/1.1
> Host: localhost:5984
> Accept: */*
> Content-Type: application/json
> Content-Length: 45
>
< HTTP/1.1 415 Unsupported Media Type
< Server: CouchDB/0.10.0a767828 (Erlang OTP/R12B)
< Date: Thu, 23 Apr 2009 08:15:17 GMT
< Content-Type: text/plain;charset=utf-8
< Content-Length: 84
< Cache-Control: must-revalidate
<
{"error":"bad_content_type","reason":"Invalid Content-Type header for form
upload"}
* Connection #0 to host localhost left intact
* Closing connection #0
I was getting a different error last evening when I was running on a 0.9
version. That error was ..
{"error":"badmatch","reason":"{\"application/json\",[]}"}
The current one runs on a fresh checkout today from svn.
Any help will be appreciated.
Thanks.
- Debasish
Re: problem with temp view
Posted by Paul Davis <pa...@gmail.com>.
On Thu, Apr 23, 2009 at 3:10 PM, Brian Candler <B....@pobox.com> wrote:
> On Thu, Apr 23, 2009 at 01:53:09PM +0530, Debasish Ghosh wrote:
>> $ curl -vX POST -H "Content-Type: application/json" -d '{"map" :
>> "function(doc) { emit(null, doc) }"}'
>> http://localhost:5984/hello-world/_tmp_view
>>
>> the error that I get is the following ..
>>
>> {"error":"bad_content_type","reason":"Invalid Content-Type header for form
>> upload"}
>
> It's _temp_view, not _tmp_view.
>
> There have been some changes made recently which mean that POSTs which
> aren't application/x-form-post are rejected.
POSTs to a /db_name/docid are now rejected if they're not multipart/form-data
However names beginning with an
> underscore are reserved.
>
Not at all. Couch will use anything you specify in the ini files with
no complaint. Underscores are just preferred because docids can't
start with an underscore if they're not a _local or _design document.
> A quick check suggests that things are a bit too lax: a PUT to /db/_tmp_view
> actually creates a document with id _tmp_view (I would have thought this
> should be rejected?)
>
It most definitely should be. There should be a test case that checks
for that somewhere. If not could you add a ticket to JIRA with a
failing JS test?
> I believe it's possible to use POST to create an attachment. Perhaps CouchDB
> thinks that your post to /db/_tmp_view is an attempt to create an attachment
> on a document whose id is _tmp_view?
>
Yep.
> It's certainly a very confusing error.
>
> Regards,
>
> Brian.
>
Paul Davis
Re: problem with temp view
Posted by Brian Candler <B....@pobox.com>.
On Thu, Apr 23, 2009 at 01:53:09PM +0530, Debasish Ghosh wrote:
> $ curl -vX POST -H "Content-Type: application/json" -d '{"map" :
> "function(doc) { emit(null, doc) }"}'
> http://localhost:5984/hello-world/_tmp_view
>
> the error that I get is the following ..
>
> {"error":"bad_content_type","reason":"Invalid Content-Type header for form
> upload"}
It's _temp_view, not _tmp_view.
There have been some changes made recently which mean that POSTs which
aren't application/x-form-post are rejected. However names beginning with an
underscore are reserved.
A quick check suggests that things are a bit too lax: a PUT to /db/_tmp_view
actually creates a document with id _tmp_view (I would have thought this
should be rejected?)
I believe it's possible to use POST to create an attachment. Perhaps CouchDB
thinks that your post to /db/_tmp_view is an attempt to create an attachment
on a document whose id is _tmp_view?
It's certainly a very confusing error.
Regards,
Brian.
Re: problem with temp view
Posted by Paul Davis <pa...@gmail.com>.
Debasish,
The end point you want is _temp_view, not _tmp_view.
Paul Davis
On Thu, Apr 23, 2009 at 4:23 AM, Debasish Ghosh
<gh...@gmail.com> wrote:
> Hi -
>
> I have been facing a problem with temp view creation from command line. When
> I try ..
>
> $ curl -vX POST -H "Content-Type: application/json" -d '{"map" :
> "function(doc) { emit(null, doc) }"}'
> http://localhost:5984/hello-world/_tmp_view
>
> the error that I get is the following ..
>
> {"error":"bad_content_type","reason":"Invalid Content-Type header for form
> upload"}
>
> The following is the complete response that I get ..
>
> $ curl -vX POST -H "Content-Type: application/json" -d '{"map" :
> "function(doc) { emit(null, doc) }"}'
> http://localhost:5984/hello-world/_tmp_view
> * About to connect() to localhost port 5984 (#0)
> * Trying 127.0.0.1... connected
> * Connected to localhost (127.0.0.1) port 5984 (#0)
>> POST /hello-world/_tmp_view HTTP/1.1
>> User-Agent: curl/7.18.0 (i486-pc-linux-gnu) libcurl/7.18.0 OpenSSL/0.9.8g
> zlib/1.2.3.3 libidn/1.1
>> Host: localhost:5984
>> Accept: */*
>> Content-Type: application/json
>> Content-Length: 45
>>
> < HTTP/1.1 415 Unsupported Media Type
> < Server: CouchDB/0.10.0a767828 (Erlang OTP/R12B)
> < Date: Thu, 23 Apr 2009 08:15:17 GMT
> < Content-Type: text/plain;charset=utf-8
> < Content-Length: 84
> < Cache-Control: must-revalidate
> <
> {"error":"bad_content_type","reason":"Invalid Content-Type header for form
> upload"}
> * Connection #0 to host localhost left intact
> * Closing connection #0
>
> I was getting a different error last evening when I was running on a 0.9
> version. That error was ..
>
> {"error":"badmatch","reason":"{\"application/json\",[]}"}
>
> The current one runs on a fresh checkout today from svn.
>
> Any help will be appreciated.
>
> Thanks.
> - Debasish
>