matt
matt

Reputation: 2039

Copy JSON directly from web URL to couchDB with cURL

Is it possible to insert the result of a curl -X GET (which is JSON) directly into a couchDB database?

ie something like.

>>> curl -X GET -H "some_header" http://some_web_JSON -X POST http://127.0.0.1:port/some_DB/_bulk_docs

Splitting the process up seems to work but, I can't seem to get the syntax right to do it in one go (presupposing it's even possible)

>>>  curl -X GET -H "some_header" http://some_web_JSON > outfile.json
>>>  curl @outfile.json -X POST http://127.0.0.1:port/some_DB/_bulk_docs

Upvotes: 0

Views: 126

Answers (1)

BlueM
BlueM

Reputation: 3851

As often in such cases, the good old Unix pipe combined with reading from stdin is the solution:

curl http://example.com/ | curl -s -T - -H 'Content-Type: application/json' -X POST http://127.0.0.1:5984/test/_bulk_docs

Upvotes: 1

Related Questions