incubator-couchdb-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Robert Newson <robert.new...@gmail.com>
Subject Re: curl POST to couchdb's _temp_view on OSX => invalid UTF-8
Date Thu, 25 Nov 2010 18:41:09 GMT
Because this;

{"map": "function(doc) {emit(null, doc) }"

is not valid JSON. Try this;

{"map": "function(doc) {emit(null, doc) }"}

B.

On Thu, Nov 25, 2010 at 6:36 PM, Florian Leitner
<florian.leitner@gmail.com> wrote:
> Hi there,
>
> I've got a peculiar problem with the UTF-8 encoding in CouchDB. I
> installed the latest CouchDBX.app for
> OSX (CouchDB version 1.0.1, curl version 7.19.7, OSX version 10.6.4)
> and all worked nicely so far. However, now I am trying to POST to the
> _temp_view of my "hello-world" database, and I get the "invalid UTF-8
> JSON" error without knowing what I am doing wrong - curl worked nicely
> for all other commands and if I run the view from Futon, it works
> nicely, too. Here is what happens with curl (I have three documents in
> "hello-world"):
>
> $ curl-json -vX POST "$DB/_temp_view" -d '{"map": "function(doc) {
> emit(null, doc) }"'
> * About to connect() to 127.0.0.1 port 5984 (#0)
> *   Trying 127.0.0.1... connected
> * Connected to 127.0.0.1 (127.0.0.1) port 5984 (#0)
>> POST /hello-world/_temp_view 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: 127.0.0.1:5984
>> Accept: */*
>> Content-Type: application/json;charset=utf-8
>> Content-Length: 43
>>
> < HTTP/1.1 400 Bad Request
> < Server: CouchDB/1.0.1 (Erlang OTP/R13B)
> < Date: Thu, 25 Nov 2010 18:19:07 GMT
> < Content-Type: text/plain;charset=utf-8
> < Content-Length: 54
> < Cache-Control: must-revalidate
> <
> {"error":"bad_request","reason":"invalid UTF-8 JSON"}
> * Connection #0 to host 127.0.0.1 left intact
> * Closing connection #0
>
> Here is the request against the database (with some spaces between
> key/value pairs to make it readable):
>
> $ curl-json $DB
> {"db_name":"hello-world", "doc_count":3, "doc_del_count":6,
> "update_seq":16, "purge_seq":0, "compact_running":false,
> "disk_size":61529, "instance_start_time":"1290702185923299",
> "disk_format_version":5, "committed_update_seq":16}
>
> Last but not least, I've aliased curl-json as such:
>
> alias curl-json='curl -H"Content-Type: application/json;charset=utf-8"'
>
> I've also tried to leave out the charset part, naturally, to no avail.
> DB is set to (as guessed):
>
> DB=http://127.0.0.1:5984/hello-world
>
> So can someone tell me why I am getting this UTF-8 issue? I could POST
> documents without encoding problems, put now POSTing to _temp_view seems to
> fail. Any help appreciated.
>
> Thanks,
> Florian
>

Mime
View raw message