You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@couchdb.apache.org by "john.tiger" <jo...@gmail.com> on 2012/02/17 03:34:28 UTC

PUT json data

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

Re: PUT json data

Posted by Robert Newson <rn...@apache.org>.
While I think your attitude to all the help you've received on this
thread speaks for itself, I will only say that we welcome
contributions to improve the wiki (write access is, sadly, invite-only
as our wiki is the target of aggressive spamming) and suggestions to
improve the API.

If you do wish to contribute to the documentation, please sign up for
an account on the wiki and start a new thread to user@ asking for
write permission.

B.

On 19 February 2012 07:52, Benoit Chesneau <bc...@gmail.com> wrote:
> On Sunday, February 19, 2012, john.tiger <jo...@gmail.com> wrote:
>> On 02/18/2012 02:59 AM, Robert Newson wrote:
>>>
>>> See http://wiki.apache.org/couchdb/HTTP_Bulk_Document_API and
>>> particularly
> http://wiki.apache.org/couchdb/HTTP_Bulk_Document_API#Modify_Multiple_Documents_With_a_Single_Request
> .
>>
>> yes, I can read.  While the docs might be clear to you they are not clear
> to myself and others (based on questions I found searching).  Are you
> refusing contributions for clearer documentation ?  That kind of attitude
> is really stupid.
>>
> he was. just pointing you to the doc so you can have a clear view. What is
> stupid here is your reaction.
>
> There is a process described on the wiki to participate to the doc.  A jira
> is here to open ticket. Other way is to open a thread like you did. what is
> not clear is why it's difficult to add a list to a doc property. I suspect
> that what you want is bulk doc streaming. Can you describe more what you're
> trying to solve?
>
> -benoît
>
>>
>>
>>
>>
>>
>>> B.
>>>
>>> On 17 February 2012 17:49, john.tiger<jo...@gmail.com>  wrote:
>>>>
>>>> On 02/17/2012 03:49 AM, Robert Newson wrote:
>>>>>
>>>>> an "array of json objects" posted to /dbname is not valid input for
>>>>> the CouchDB API.
>>>>>
>>>>> As others have noted, you can POST a single json object to /dbname, or
>>>>> PUT a single json object to /dbname/docname, or POST multiple
>>>>> documents to /dbname/_bulk_docs using the {"docs":[]} format.
>>>>>
>>>>> http://wiki.apache.org/couchdb/HTTP_Document_API
>>>>
>>>> okay, I see that _bulk_docs actually does not keep the extra "docs":[]
> layer
>>>> but loads each record individually.
>>>>
>>>> I do think this should still be changed since if extracting a big json
> data
>>>> set - it is a pain to append the {"docs":
>>>>
>>>> Also the wiki is not that clear - how can I submit a brief description
> of
>>>> this to the wiki page ?  any password or process required ?
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>> B.
>>>>>
>>>>> On 17 February 2012 07:35, Alexander Shorin<kx...@gmail.com>    wrote:
>>>>>>
>>>>>> On Fri, Feb 17, 2012 at 10:15 AM, john.tiger<
> john.tigernassau@gmail.com>
>>>>>>  wrote:
>>>>>>>
>>>>>>> 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.
>>>>>>>
>>>>>> JSON array might be valid from syntax point, but it is invalid from
>>>>>> point of expected data for /db/_bulk_docs resource.
>>>>>>
>>>>>>
>>>>>> --
>>>>>> ,,,^..^,,,
>>>>
>>
>>

Re: PUT json data

Posted by Benoit Chesneau <bc...@gmail.com>.
On Sunday, February 19, 2012, john.tiger <jo...@gmail.com> wrote:
> On 02/18/2012 02:59 AM, Robert Newson wrote:
>>
>> See http://wiki.apache.org/couchdb/HTTP_Bulk_Document_API and
>> particularly
http://wiki.apache.org/couchdb/HTTP_Bulk_Document_API#Modify_Multiple_Documents_With_a_Single_Request
.
>
> yes, I can read.  While the docs might be clear to you they are not clear
to myself and others (based on questions I found searching).  Are you
refusing contributions for clearer documentation ?  That kind of attitude
is really stupid.
>
he was. just pointing you to the doc so you can have a clear view. What is
stupid here is your reaction.

There is a process described on the wiki to participate to the doc.  A jira
is here to open ticket. Other way is to open a thread like you did. what is
not clear is why it's difficult to add a list to a doc property. I suspect
that what you want is bulk doc streaming. Can you describe more what you're
trying to solve?

-benoît

>
>
>
>
>
>> B.
>>
>> On 17 February 2012 17:49, john.tiger<jo...@gmail.com>  wrote:
>>>
>>> On 02/17/2012 03:49 AM, Robert Newson wrote:
>>>>
>>>> an "array of json objects" posted to /dbname is not valid input for
>>>> the CouchDB API.
>>>>
>>>> As others have noted, you can POST a single json object to /dbname, or
>>>> PUT a single json object to /dbname/docname, or POST multiple
>>>> documents to /dbname/_bulk_docs using the {"docs":[]} format.
>>>>
>>>> http://wiki.apache.org/couchdb/HTTP_Document_API
>>>
>>> okay, I see that _bulk_docs actually does not keep the extra "docs":[]
layer
>>> but loads each record individually.
>>>
>>> I do think this should still be changed since if extracting a big json
data
>>> set - it is a pain to append the {"docs":
>>>
>>> Also the wiki is not that clear - how can I submit a brief description
of
>>> this to the wiki page ?  any password or process required ?
>>>
>>>
>>>
>>>
>>>
>>>
>>>> B.
>>>>
>>>> On 17 February 2012 07:35, Alexander Shorin<kx...@gmail.com>    wrote:
>>>>>
>>>>> On Fri, Feb 17, 2012 at 10:15 AM, john.tiger<
john.tigernassau@gmail.com>
>>>>>  wrote:
>>>>>>
>>>>>> 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.
>>>>>>
>>>>> JSON array might be valid from syntax point, but it is invalid from
>>>>> point of expected data for /db/_bulk_docs resource.
>>>>>
>>>>>
>>>>> --
>>>>> ,,,^..^,,,
>>>
>
>

Re: PUT json data

Posted by "john.tiger" <jo...@gmail.com>.
fine - I can see this is a group of arrogant programmers who don't want 
others to contribute to make things better - if you think the couchdb 
documentation is good, well, it's those that think they know that 
actually don't - but then you probably can't understand that.   We won't 
waste any more time here.


On 02/18/2012 06:46 PM, Keith Gable wrote:
> The docs are crystal clear to me, and I don't use the bulk docs API. Though
> I do admit that the docs do assume you know how to use cURL, and if you
> don't, then I can see where they wouldn't be very helpful.
>
> I have noticed that there are a lot of people that attempt to use CouchDB
> without a background in REST APIs... that's basically the only type of API
> you do as a Rails programmer, which is another reason why the CouchDB API
> is easy for me to follow.
>
> CouchDB also requires you to forget about everything you know about
> relational databases and SQL. Think more about sorting and labelling sheets
> of paper.
> On Feb 18, 2012 7:34 PM, "john.tiger"<jo...@gmail.com>  wrote:
>
>> On 02/18/2012 02:59 AM, Robert Newson wrote:
>>
>>> See http://wiki.apache.org/**couchdb/HTTP_Bulk_Document_API<http://wiki.apache.org/couchdb/HTTP_Bulk_Document_API>and
>>> particularly http://wiki.apache.org/**couchdb/HTTP_Bulk_Document_**
>>> API#Modify_Multiple_Documents_**With_a_Single_Request<http://wiki.apache.org/couchdb/HTTP_Bulk_Document_API#Modify_Multiple_Documents_With_a_Single_Request>
>>> .
>>>
>> yes, I can read.  While the docs might be clear to you they are not clear
>> to myself and others (based on questions I found searching).  Are you
>> refusing contributions for clearer documentation ?  That kind of attitude
>> is really stupid.
>>
>>
>>
>>
>>
>>
>>   B.
>>> On 17 February 2012 17:49, john.tiger<jo...@gmail.com>>
>>>   wrote:
>>>
>>>> On 02/17/2012 03:49 AM, Robert Newson wrote:
>>>>
>>>>> an "array of json objects" posted to /dbname is not valid input for
>>>>> the CouchDB API.
>>>>>
>>>>> As others have noted, you can POST a single json object to /dbname, or
>>>>> PUT a single json object to /dbname/docname, or POST multiple
>>>>> documents to /dbname/_bulk_docs using the {"docs":[]} format.
>>>>>
>>>>> http://wiki.apache.org/**couchdb/HTTP_Document_API<http://wiki.apache.org/couchdb/HTTP_Document_API>
>>>>>
>>>> okay, I see that _bulk_docs actually does not keep the extra "docs":[]
>>>> layer
>>>> but loads each record individually.
>>>>
>>>> I do think this should still be changed since if extracting a big json
>>>> data
>>>> set - it is a pain to append the {"docs":
>>>>
>>>> Also the wiki is not that clear - how can I submit a brief description of
>>>> this to the wiki page ?  any password or process required ?
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>   B.
>>>>> On 17 February 2012 07:35, Alexander Shorin<kx...@gmail.com>     wrote:
>>>>>
>>>>>> On Fri, Feb 17, 2012 at 10:15 AM, john.tiger<john.tigernassau@**
>>>>>> gmail.com<jo...@gmail.com>>
>>>>>>   wrote:
>>>>>>
>>>>>>> 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<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.
>>>>>>>
>>>>>>>   JSON array might be valid from syntax point, but it is invalid from
>>>>>> point of expected data for /db/_bulk_docs resource.
>>>>>>
>>>>>>
>>>>>> --
>>>>>> ,,,^..^,,,
>>>>>>


Re: PUT json data

Posted by Keith Gable <zi...@ignition-project.com>.
The docs are crystal clear to me, and I don't use the bulk docs API. Though
I do admit that the docs do assume you know how to use cURL, and if you
don't, then I can see where they wouldn't be very helpful.

I have noticed that there are a lot of people that attempt to use CouchDB
without a background in REST APIs... that's basically the only type of API
you do as a Rails programmer, which is another reason why the CouchDB API
is easy for me to follow.

CouchDB also requires you to forget about everything you know about
relational databases and SQL. Think more about sorting and labelling sheets
of paper.
On Feb 18, 2012 7:34 PM, "john.tiger" <jo...@gmail.com> wrote:

> On 02/18/2012 02:59 AM, Robert Newson wrote:
>
>> See http://wiki.apache.org/**couchdb/HTTP_Bulk_Document_API<http://wiki.apache.org/couchdb/HTTP_Bulk_Document_API>and
>> particularly http://wiki.apache.org/**couchdb/HTTP_Bulk_Document_**
>> API#Modify_Multiple_Documents_**With_a_Single_Request<http://wiki.apache.org/couchdb/HTTP_Bulk_Document_API#Modify_Multiple_Documents_With_a_Single_Request>
>> .
>>
> yes, I can read.  While the docs might be clear to you they are not clear
> to myself and others (based on questions I found searching).  Are you
> refusing contributions for clearer documentation ?  That kind of attitude
> is really stupid.
>
>
>
>
>
>
>  B.
>>
>> On 17 February 2012 17:49, john.tiger<jo...@gmail.com>>
>>  wrote:
>>
>>> On 02/17/2012 03:49 AM, Robert Newson wrote:
>>>
>>>> an "array of json objects" posted to /dbname is not valid input for
>>>> the CouchDB API.
>>>>
>>>> As others have noted, you can POST a single json object to /dbname, or
>>>> PUT a single json object to /dbname/docname, or POST multiple
>>>> documents to /dbname/_bulk_docs using the {"docs":[]} format.
>>>>
>>>> http://wiki.apache.org/**couchdb/HTTP_Document_API<http://wiki.apache.org/couchdb/HTTP_Document_API>
>>>>
>>>
>>> okay, I see that _bulk_docs actually does not keep the extra "docs":[]
>>> layer
>>> but loads each record individually.
>>>
>>> I do think this should still be changed since if extracting a big json
>>> data
>>> set - it is a pain to append the {"docs":
>>>
>>> Also the wiki is not that clear - how can I submit a brief description of
>>> this to the wiki page ?  any password or process required ?
>>>
>>>
>>>
>>>
>>>
>>>
>>>  B.
>>>>
>>>> On 17 February 2012 07:35, Alexander Shorin<kx...@gmail.com>    wrote:
>>>>
>>>>> On Fri, Feb 17, 2012 at 10:15 AM, john.tiger<john.tigernassau@**
>>>>> gmail.com <jo...@gmail.com>>
>>>>>  wrote:
>>>>>
>>>>>> 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<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.
>>>>>>
>>>>>>  JSON array might be valid from syntax point, but it is invalid from
>>>>> point of expected data for /db/_bulk_docs resource.
>>>>>
>>>>>
>>>>> --
>>>>> ,,,^..^,,,
>>>>>
>>>>
>>>
>

Re: PUT json data

Posted by "john.tiger" <jo...@gmail.com>.
On 02/18/2012 02:59 AM, Robert Newson wrote:
> See http://wiki.apache.org/couchdb/HTTP_Bulk_Document_API and
> particularly http://wiki.apache.org/couchdb/HTTP_Bulk_Document_API#Modify_Multiple_Documents_With_a_Single_Request.
yes, I can read.  While the docs might be clear to you they are not 
clear to myself and others (based on questions I found searching).  Are 
you refusing contributions for clearer documentation ?  That kind of 
attitude is really stupid.






> B.
>
> On 17 February 2012 17:49, john.tiger<jo...@gmail.com>  wrote:
>> On 02/17/2012 03:49 AM, Robert Newson wrote:
>>> an "array of json objects" posted to /dbname is not valid input for
>>> the CouchDB API.
>>>
>>> As others have noted, you can POST a single json object to /dbname, or
>>> PUT a single json object to /dbname/docname, or POST multiple
>>> documents to /dbname/_bulk_docs using the {"docs":[]} format.
>>>
>>> http://wiki.apache.org/couchdb/HTTP_Document_API
>>
>> okay, I see that _bulk_docs actually does not keep the extra "docs":[] layer
>> but loads each record individually.
>>
>> I do think this should still be changed since if extracting a big json data
>> set - it is a pain to append the {"docs":
>>
>> Also the wiki is not that clear - how can I submit a brief description of
>> this to the wiki page ?  any password or process required ?
>>
>>
>>
>>
>>
>>
>>> B.
>>>
>>> On 17 February 2012 07:35, Alexander Shorin<kx...@gmail.com>    wrote:
>>>> On Fri, Feb 17, 2012 at 10:15 AM, john.tiger<jo...@gmail.com>
>>>>   wrote:
>>>>> 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.
>>>>>
>>>> JSON array might be valid from syntax point, but it is invalid from
>>>> point of expected data for /db/_bulk_docs resource.
>>>>
>>>>
>>>> --
>>>> ,,,^..^,,,
>>


Re: PUT json data

Posted by Robert Newson <rn...@apache.org>.
See http://wiki.apache.org/couchdb/HTTP_Bulk_Document_API and
particularly http://wiki.apache.org/couchdb/HTTP_Bulk_Document_API#Modify_Multiple_Documents_With_a_Single_Request.

B.

On 17 February 2012 17:49, john.tiger <jo...@gmail.com> wrote:
> On 02/17/2012 03:49 AM, Robert Newson wrote:
>>
>> an "array of json objects" posted to /dbname is not valid input for
>> the CouchDB API.
>>
>> As others have noted, you can POST a single json object to /dbname, or
>> PUT a single json object to /dbname/docname, or POST multiple
>> documents to /dbname/_bulk_docs using the {"docs":[]} format.
>>
>> http://wiki.apache.org/couchdb/HTTP_Document_API
>
>
> okay, I see that _bulk_docs actually does not keep the extra "docs":[] layer
> but loads each record individually.
>
> I do think this should still be changed since if extracting a big json data
> set - it is a pain to append the {"docs":
>
> Also the wiki is not that clear - how can I submit a brief description of
> this to the wiki page ?  any password or process required ?
>
>
>
>
>
>
>>
>> B.
>>
>> On 17 February 2012 07:35, Alexander Shorin<kx...@gmail.com>  wrote:
>>>
>>> On Fri, Feb 17, 2012 at 10:15 AM, john.tiger<jo...@gmail.com>
>>>  wrote:
>>>>
>>>> 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.
>>>>
>>> JSON array might be valid from syntax point, but it is invalid from
>>> point of expected data for /db/_bulk_docs resource.
>>>
>>>
>>> --
>>> ,,,^..^,,,
>
>

Re: PUT json data

Posted by Benoit Chesneau <bc...@gmail.com>.
On Friday, February 17, 2012, john.tiger <jo...@gmail.com> wrote:
> On 02/17/2012 03:49 AM, Robert Newson wrote:
>>
>> an "array of json objects" posted to /dbname is not valid input for
>> the CouchDB API.
>>
>> As others have noted, you can POST a single json object to /dbname, or
>> PUT a single json object to /dbname/docname, or POST multiple
>> documents to /dbname/_bulk_docs using the {"docs":[]} format.
>>
>> http://wiki.apache.org/couchdb/HTTP_Document_API
>
> okay, I see that _bulk_docs actually does not keep the extra "docs":[]
layer but loads each record individually.
>
> I do think this should still be changed since if extracting a big json
data set - it is a pain to append the {"docs":
>
> Also the wiki is not that clear - how can I submit a brief description of
this to the wiki page ?  any password or process required ?
>
>
>
>
>
>>
>> B.
>>
>> On 17 February 2012 07:35, Alexander Shorin<kx...@gmail.com>  wrote:
>>>
>>> On Fri, Feb 17, 2012 at 10:15 AM, john.tiger<jo...@gmail.com>
 wrote:
>>>>
>>>> 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.
>>>>
>>> JSON array might be valid from syntax point, but it is invalid from
>>> point of expected data for /db/_bulk_docs resource.
>>>
>>>
>>> --
>>> ,,,^..^,,,
>
>


yes you can ask htere for an access to the doc. For the other thing, why
not openning a ticket for improvement? Also something need to be found to
pass other parameters.

benoît

Re: PUT json data

Posted by "john.tiger" <jo...@gmail.com>.
On 02/17/2012 03:49 AM, Robert Newson wrote:
> an "array of json objects" posted to /dbname is not valid input for
> the CouchDB API.
>
> As others have noted, you can POST a single json object to /dbname, or
> PUT a single json object to /dbname/docname, or POST multiple
> documents to /dbname/_bulk_docs using the {"docs":[]} format.
>
> http://wiki.apache.org/couchdb/HTTP_Document_API

okay, I see that _bulk_docs actually does not keep the extra "docs":[] 
layer but loads each record individually.

I do think this should still be changed since if extracting a big json 
data set - it is a pain to append the {"docs":

Also the wiki is not that clear - how can I submit a brief description 
of this to the wiki page ?  any password or process required ?





>
> B.
>
> On 17 February 2012 07:35, Alexander Shorin<kx...@gmail.com>  wrote:
>> On Fri, Feb 17, 2012 at 10:15 AM, john.tiger<jo...@gmail.com>  wrote:
>>> 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.
>>>
>> JSON array might be valid from syntax point, but it is invalid from
>> point of expected data for /db/_bulk_docs resource.
>>
>>
>> --
>> ,,,^..^,,,


Re: PUT json data

Posted by Robert Newson <rn...@apache.org>.
an "array of json objects" posted to /dbname is not valid input for
the CouchDB API.

As others have noted, you can POST a single json object to /dbname, or
PUT a single json object to /dbname/docname, or POST multiple
documents to /dbname/_bulk_docs using the {"docs":[]} format.

http://wiki.apache.org/couchdb/HTTP_Document_API

B.

On 17 February 2012 07:35, Alexander Shorin <kx...@gmail.com> wrote:
> On Fri, Feb 17, 2012 at 10:15 AM, john.tiger <jo...@gmail.com> wrote:
>> 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.
>>
>
> JSON array might be valid from syntax point, but it is invalid from
> point of expected data for /db/_bulk_docs resource.
>
>
> --
> ,,,^..^,,,

Re: PUT json data

Posted by Alexander Shorin <kx...@gmail.com>.
On Fri, Feb 17, 2012 at 10:15 AM, john.tiger <jo...@gmail.com> wrote:
> 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.
>

JSON array might be valid from syntax point, but it is invalid from
point of expected data for /db/_bulk_docs resource.


--
,,,^..^,,,

Re: PUT json data

Posted by "john.tiger" <jo...@gmail.com>.
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<jo...@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


Re: PUT json data

Posted by Alexander Shorin <kx...@gmail.com>.
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 <jo...@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

Re: PUT json data

Posted by Mark Hahn <ma...@hahnca.com>.
http://jsonlint.com/ says it is valid.

On Thu, Feb 16, 2012 at 6:34 PM, john.tiger <jo...@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
>