0

I am using the following curl command to upload data to CouchDB:

 curl -d @abcd.json -H "Content-Type: application/json" -X POST http://@localhost:5984/database/_bulk_docs 

The file contains multiple JSON documents and is valid JSON.

The response I get is: {"error":"bad_request","reason":"Request body must be a JSON object"}

I have studied other answers to similar questions but don't seem to be able to find the reason for the error.

(The file does not have a 'BOM' as far as I can see.)

I am running on Windows 10.

I have tried using the RESTClient addon in Firefox with the same result.

1
  • Please, show the example content of abcd.json file. Are the contained jsons supposed to be separated documents in couchDB? Commented Feb 9, 2022 at 18:55

1 Answer 1

2

To solve this I have found that one needs an added structure in the input file, nl. an additional:

 { "docs": 

before the first "[" of the first JSON document in the file(naturally with closing "}") then everything works.

Sorry for the inconvenience.

This post jogged my thinking.

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.