incubator-couchdb-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Florian Leitner <florian.leit...@gmail.com>
Subject Re: curl POST to couchdb's _temp_view on OSX => invalid UTF-8
Date Fri, 26 Nov 2010 14:39:37 GMT
Great tip, thanks, Mark!

--Florian

On 26 November 2010 15:22, Mark J. Reed <markjreed@gmail.com> wrote:
> When hand-constructing or -editing JSON, it's a good idea to run it
> through a parser to make sure it's valid. Modern python installs come
> with a module for that.  Just save the JSON in a file and run
>
> python -mjson.tool <filename
>
> It will either spit out an error message or else pretty-print the
> JSON, in which case you know it's valid. Then you can use the
> -d@filename option to feed the file directly to curl.
>
> On Friday, November 26, 2010, Florian Leitner <florian.leitner@gmail.com> wrote:
>> How embarrassing... Well, thanks lots for the hint!
>>
>> -- Florian
>>
>> On 26 November 2010 10:23, JC de Villa <jc.devilla@gmail.com> wrote:
>>> You're missing a closing curly bracket before that last single quote.
>>>
>>> JC de Villa
>>>
>>>
>>> On Fri, Nov 26, 2010 at 2:36 AM, 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
>>>>
>>>
>>
>
> --
> Mark J. Reed <markjreed@gmail.com>
>

Mime
View raw message