Hi Couchbase,
We are experiencing some weird behavior on Bucket REST API after upgrading Couchbase 4.6.3 to 5.0. Documents created using Bucket API REST are stored empty.
We use some .bat and .sh scripts in order to populate our buckets right before we start doing stress testing and user driven tests. Each bucket on our Couchbase DB has its user account with specific access role. Still, we use the Administrator user to call Bucket REST API.
The next command is an example of one of many curl commands we fire from .bat and .sh scripts. This particularly example belongs to a Windows .bat script:
curl -i -k -u Administrator: -H âContent-Type: application/jsonâ -X POST http://<cb_ip>:8091/pools/default/buckets/places/docs/ct:ZZ:en -d @city_unknown_en.json
city_unknown_en.json file:
{
âctryâ: âZZâ,
âhashâ: âZZâ,
âlocalityâ: âUnknown City/Localityâ,
âadminareal2â: âUnknown Neighbourhoodâ,
âadminareal1â: âUnknown State/Provinceâ,
âtpâ: âctâ
}
curl request:
- Trying <cb_ip>âŚ
- TCP_NODELAY set
- Connected to <cb_ip> (<cb_ip>) port 8091 (#0)
- Server auth using Basic with user âAdministratorâ
POST /pools/default/buckets/places/docs/ct:ZZ:en HTTP/1.1
Host: <cb_ip>:8091
Authorization: Basic
User-Agent: curl/7.53.1
Accept: /
Content-Type: application/json
Content-Length: 165
- upload completely sent off: 165 out of 165 bytes
Couchbase response:
HTTP/1.1 200 OK
X-XSS-Protection: 1; mode=block
X-Permitted-Cross-Domain-Policies: none
X-Frame-Options: DENY
X-Content-Type-Options: nosniff
Server: Couchbase Server
Pragma: no-cache
Expires: Thu, 01 Jan 1970 00:00:00 GMT
Date: Sun, 05 Nov 2017 17:37:56 GMT
Content-Type: application/json
Content-Length: 2
Cache-Control: no-cache,no-store,must-revalidate
Despite of the 200 OK message, when we try to query that document it returns empty:
Query Editor:
select ct.* from places ct use keys [âct:ZZ:enâ]
Query Results:
[
{ }
]
And from Couchbase Web Console we see a strange warning message: âEditing of binary document is not allowedâ.
And when querying directly using REST GET method:
http://<cb_ip>:8091/pools/default/buckets/places/docs/ct:ZZ:en
Response:
{âmetaâ:{âidâ:âct:ZZ:enâ,ârevâ:â25-14f441365a6900000000000002000006â,âatt_reasonâ:âinvalid_jsonâ,âexpirationâ:0,âflagsâ:33554438},âbase64â:ââ}
We suspect from the previous response that the Bucket API REST for creation/update of documents is receiving a json payload as binary and trying to store it as json (thatâs why the invalid_json).
Questions:
- Which is the new JSON format to POST a new document?
- Are we missing a command flag?
- Do you have an example of how to do it right?
We are already in production so we need to figure the solution out as soon as possible. Thanks in advance!
Carlos