couchdb-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "john.tiger" <john.tigernas...@gmail.com>
Subject Re: PUT json data
Date Fri, 17 Feb 2012 06:15:46 GMT
On 02/16/2012 08:00 PM, Alexander Shorin wrote:
> 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

yes but the _bulk_docs docs say must have  {"docs": [.....]} - this 
seems wrong - if an array of json objects is correct json syntax, then 
couchdb should be able to import it.




>
> 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<john.tigernassau@gmail.com>  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


Mime
View raw message