I suppose that you'd like to create multiple documents at one. Than
you have to use bulk api:
http://wiki.apache.org/couchdb/HTTP_Bulk_Document_API#Modify_Multiple_Documents_With_a_Single_Request
Otherwise you should PUT single object to document resource or use
POST request to let CouchDB setup document id, but in both cases data
source should not be an array of objects. E.g.
$ cat myfile.json
{"name":"johndoe","created":"2012-02-16"}
$ curl -X POST http://localhost:5984/foo/ -d @myfile.json -H
"Content-Type: application/json"
{"ok":true,"id":"c916fb881528a36121d58c14331609ec","rev":"1-e87a6098d0409f77817207224a5508ea"}
OR
$ curl -X PUT http://localhost:5984/foo/bar -d @myfile.json -H
"Content-Type: application/json"
{"ok":true,"id":"bar","rev":"1-e87a6098d0409f77817207224a5508ea"}
More information about Document API could be found there:
http://wiki.apache.org/couchdb/HTTP_Document_API
--
,,,^..^,,,
On Fri, Feb 17, 2012 at 6:34 AM, john.tiger <[email protected]> wrote:
> something is wrong but seems right syntax
>
> myfile.json
> [{"name":"johndoe","created":"2012-02-16"},{"name":"marydoe","created":"2012-02-16"}]
>
> curl -X PUT http://127.0.0.1:5984/mydb/ -d @myfile.json -H
> "Content-Type:application/json"
>
> => not a valid json object