Sync Gateway PUT /{db}/ responds with "Bad JSON" - but JSON is valid

I’m trying to create a database via SG with the following request:

curl -i -H "Content-Type: application/json" -X PUT http://127.0.0.1:4985/newdb/ -d '{"server":"http://couchbase-server:8091:","bucket":"newdb","users":{"GUEST":{"disabled":"false","admin_channels":["*"]}}}'

However I get a “Bad JSON” response:

HTTP/1.1 400 Bad Request
Content-Type: application/json
Server: Couchbase Sync Gateway/1.4.0
Date: Wed, 16 Aug 2017 11:10:59 GMT
Content-Length: 43

{"error":"Bad Request","reason":"Bad JSON"}# 

My JSON is valid. If I send empty curly braces it creates it, but then I assume it creates a walrus-backed db which is not what I want at this stage.

So I removed "disabled":"false" and I am now getting through. This should be a clearer error message - the JSON is valid but perhaps the content is not?

try this:

curl -i -H "Content-Type: application/json" -X PUT http://127.0.0.1:4985/newdb/ -d '{"server":"http://couchbase-server:8091:","bucket":"newdb","users":{"GUEST":{"disabled":false,"admin_channels":["*"]}}}'

change

"disabled":"false"

to

"disabled":false

Ah ok that seems to work. However, I am now struggling with 501 or 502 responses, e.g. with the above request I get:

HTTP/1.1 502 Bad Gateway
Content-Type: application/json
Server: Couchbase Sync Gateway/1.4.0
Date: Wed, 16 Aug 2017 11:33:11 GMT
Content-Length: 265

{"error":"Bad Gateway","reason":" Unable to connect to Couchbase Server (connection refused). Please ensure it is running and reachable at the configured host and port.  Detailed error: HTTP error 401 Unauthorized getting \"http://couchbase-server:8091:/pools\": "}# 

couchbase-server is the name given to the docker container running Couchbase Server.

what version of SG and CB Server do you use?
maybe you should add password field.

@adamski

Remove the trailing ‘:’ from the couchbase-server URL i.e. “http://couchbase-server:8091

@atom_yang SG 1.4, CB Server 4.5.1, using Docker images with --net=couchbase option

@andy I tried that too:

curl -i -H "Content-Type: application/json" -X PUT http://127.0.0.1:4985/mynewdb/ -d '{"server":"http://couchbase-server:8091","bucket":"mynewdb","users":{"GUEST":{"disabled":false,"admin_channels":["*"]}}}'
HTTP/1.1 502 Bad Gateway
Content-Type: application/json
Server: Couchbase Sync Gateway/1.4.0
Date: Wed, 16 Aug 2017 12:08:06 GMT
Content-Length: 264

{"error":"Bad Gateway","reason":" Unable to connect to Couchbase Server (connection refused). Please ensure it is running and reachable at the configured host and port.  Detailed error: HTTP error 401 Unauthorized getting \"http://couchbase-server:8091/pools\": "}# 

Does the bucket need to exist already? I assume not…

bucket should exist.