Hi Brian,
Thanks for your help.
I've been escaping the square brackets and double quotes in curl, like
this \[\" ....\" \] - which seems to work. I'll start using -g in
curl so I don't have to escape the square braces.
Wrapping the url in single quotes results in the single quote being
interpreted as part of the url itself, and curl complains that "protocol
'http is not supported".
As for %22's... I cannot make that work at all. If I encode double
quotes as %22's in curl, couchdb complains about invalid JSON, and it
looks as if all the %'s have been stripped out and the 22's become part
of the request. For example the following request:
curl -g -X GET http:
(...url...)?startkey=[%22SYD%22,%22LAX%22,%222008-01-01T00:00:00Z%22%]&endkey=[%22SYD%22,%22LAX%22,%222008-01-05T23:59:59Z
%22]&group=true&stale=ok
....results in the following error from couchdb:
{"error":"invalid_json","reason":"[22,22,-01-01T00:00:00Z]"}
Replacing all the %22's with escaped double quotes (like this: \" )
works perfectly; I get the rows I was expecting.
Somewhere along the line, those %'s are being stripped out and the
request mangled. I will fire up my linux laptop later and see if any of
these problems exist there.
Cheers,
Kai
On 18/05/2009 13:46, Brian Candler wrote:
On Sun, May 17, 2009 at 10:17:59AM +0200, Kai Griffin - Relaxing wrote:
The trouble is, couchdb fails to return any rows when those quotes are
encoded as %22's like that.
Are you sure? Can you tun the same curl command line twice, once where it
works, and once which is identical except you replace every double quote
with %22 ?
Note 1: make sure the whole URL goes inside single quotes:
curl 'http://127.0.0.1:5984/.....'
Note 2: be careful with square brackets and curl, as it will try to perform
its own globbing on them. Either use the -g flag to curl, or encode your
square brackets as %5B and %5D.
HTH,
Brian.