I have a VM running Couchbase Community Edition 7.1.0 build 2556 and Sync Gateway/2.8.2(1;4df7a2d) CE.
I’ve set up a database called “licensees” that maps to “bucket-licensees” which currently is empty (dropped and created).
If I try to add a document to it using the REST API via curl, it is giving me an error “Bad JSON: EOF”. When I look this error up, most of what I found suggests that there’s a syntax error in my JSON file. I originally tried with a document retrieved from another databases and just tried to PUT it without modifying anything. Then I tried this simple doc:
{
"really": "yes",
"test": true
}
Command line:
curl -Ss -u 'mike.totman@safedoorpm.com:...' -H "accept: application/json" -H "Content-Type: application/json" -X PUT "http://localhost:4985/licensees/test" --data-binary @~/tmp/test.json
It still fails. I even checked to make sure that the file wasn’t encoded weirdly:
$ file -i test.json
test.json: text/plain; charset=us-ascii
I’ve tried --data-binary
, --data-ascii
, --data
, it always fails.
If I include the document contents on the command line (e.g. ... -d '{ "really":"yes","test":true}'
) it works
Here’s the secton of the Sync Gateway config file that defines the database:
"licensees": {
"server": "couchbase://127.0.0.1",
"username": "Administrator",
"password": ".",
"bucket": "bucket-licensees",
"enable_shared_bucket_access": true,
"import_docs": true,
"users": {
"GUEST": { "disabled":true, "admin_channels":["*"] },
"admin": { "password":"...", "admin_channels":["channel-licensees"], "disabled":false },
"mike.totman@safedoorpm.com": { "password":"...", "admin_channels":["channel-licensees"], "disabled":false }
},
"sync": `function(doc, oldDoc) {
requireAccess("channel-licensees");
channel("channel-licensees");
}`,
"allow_conflicts": false,
"revs_limit": 20,
"num_index_replicas": 0
},
And, for completeness, here’s the bucket config:
I’m at a loss as to why this won’t work.