Return-Path: Delivered-To: apmail-couchdb-user-archive@www.apache.org Received: (qmail 75939 invoked from network); 28 Jul 2010 07:52:35 -0000 Received: from unknown (HELO mail.apache.org) (140.211.11.3) by 140.211.11.9 with SMTP; 28 Jul 2010 07:52:35 -0000 Received: (qmail 82407 invoked by uid 500); 28 Jul 2010 07:52:34 -0000 Delivered-To: apmail-couchdb-user-archive@couchdb.apache.org Received: (qmail 82201 invoked by uid 500); 28 Jul 2010 07:52:31 -0000 Mailing-List: contact user-help@couchdb.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: user@couchdb.apache.org Delivered-To: mailing list user@couchdb.apache.org Received: (qmail 82192 invoked by uid 99); 28 Jul 2010 07:52:30 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 28 Jul 2010 07:52:30 +0000 X-ASF-Spam-Status: No, hits=0.7 required=10.0 tests=NORMAL_HTTP_TO_IP,SPF_NEUTRAL,WEIRD_PORT X-Spam-Check-By: apache.org Received-SPF: neutral (nike.apache.org: local policy) Received: from [209.85.160.180] (HELO mail-gy0-f180.google.com) (209.85.160.180) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 28 Jul 2010 07:52:22 +0000 Received: by gye5 with SMTP id 5so2713439gye.11 for ; Wed, 28 Jul 2010 00:52:00 -0700 (PDT) MIME-Version: 1.0 Received: by 10.150.202.9 with SMTP id z9mr12159718ybf.211.1280303520728; Wed, 28 Jul 2010 00:52:00 -0700 (PDT) Received: by 10.150.133.13 with HTTP; Wed, 28 Jul 2010 00:52:00 -0700 (PDT) In-Reply-To: <4C4F4E74.6080908@gmail.com> References: <4C4F4E74.6080908@gmail.com> Date: Wed, 28 Jul 2010 19:52:00 +1200 Message-ID: Subject: =?windows-1252?Q?Re=3A_Curl_giving_=93Invalid_UTF=2D8_JSON=94_error_from_?= =?windows-1252?Q?CouchDb_although_JSON_is_fine=3F_Any_ideas=3F?= From: Dave Cottlehuber To: user@couchdb.apache.org, couchdb-relax@googlegroups.com Content-Type: text/plain; charset=ISO-8859-1 X-Virus-Checked: Checked by ClamAV on apache.org Hi Andrew This is a windows thing regarding quoting - a real PITA. Unfortunately cmd.exe shell on windows doesn't parse this correctly. The rules for when escaping with a "" or a ^" or a \" are a bit vague but this works: C:\tmp>curl -X PUT http://@127.0.0.1:5984/albums/6e1295ed6c29495e54cc05947f18c8af -d "{\"title\":\"There is Nothing Left to Lose\",\"artist\":\"Foo Fighters\"}" {"ok":true,"id":"6e1295ed6c29495e54cc05947f18c8af","rev":"1-4b39c2971c9ad54cb37e08fa02fec636"} C:\tmp> "basically you need to \"escape\" all \"quotes\" within your JSON" Is there any way we to get this updated in the online book? A+ Dave On 28 July 2010 09:24, Andrew Woodcock wrote: > > > Hi there, > > this is probably a real noob problem but I am experiencing an issue where > whenever I try to create a document on CouchDB using curl, I get an "Invalid > UTF-8 JSON" error. The example I am trying to use is actually from > O'Reilly's book "CouchDB: The Definitive Guide" and I am pretty sure that I > have tried it before and got it to work. Here's the command: > > |curl-X PUT > http://username:password@127.0.0.1:5984/albums/6e1295ed6c29495e54cc05947f18c8af > -d '{"title":"There is Nothing Left to Lose","artist":"Foo Fighters"}' > | > > The database albums exists and the username and password are correct. I have > checked this with JSONLint and the JSON is valid and I am at a loss ... > presumably there is an issue with the CouchDB server itself but it appears > to be running correctly ... any ideas? This is driving me nuts! > > I am running CouchDB 0.11 on Windows 7. curl is installed and working > correctly as far as I can tell. Sofa is working correctly and I can create > documents via Sofa with no issues. > > Thanks, > > Andrew > >