Couchbase Server and Sync Gateway (Error Unmarshaling doc)


Hi guys, i am trying to follow the hello couchbase example. But i keep getting the wrong output. My server console on command prompt keep getting
*"2016-06-13T15:44:49.193+08:00 WARNING: changeCache: Error unmarshaling doc “21st_amendment_brewery_cafe-amendment_pale_ale”: – db.(changeCache).DocChanged.func1() at change_cache.go:327"

while executing the hello-couchbase.js file the output is
Amendment Pale Ale, ABV: 5.2
{ cas: CouchbaseCas<62246400317204>, token: undefined }

it is a different output from the 1 stated in the tutorial

“log”: [“REST”],
“adminInterface”: “”,
“interface”: “”,
“databases”: {
“db”: {
“server”: “http://localhost:8091”,
“GUEST”: {“disabled”: false, “admin_channels”: ["*"] }

var couchbase = require(“couchbase”);

// Connect to Couchbase Server

var cluster = new couchbase.Cluster(‘’);
var bucket = cluster.openBucket(‘beer-sample’, function(err) {
if (err) {
// Failed to make a connection to the Couchbase cluster.
throw err;

// Retrieve a document

bucket.get(‘21st_amendment_brewery_cafe-amendment_pale_ale’, function(err, result) {
if (err) {
// Failed to retrieve key
throw err;

var doc = result.value;

console.log( + ', ABV: ' + doc.abv);

// Store a document

doc.comment = "Random beer from Norway";

bucket.replace('21st_amendment_brewery_cafe-amendment_pale_ale', doc, function(err, result) {
  if (err) {
    // Failed to replace key
    throw err;


  // Success!



That’s the expected Sync Gateway warning for documents that don’t have the sync metadata required by Sync Gateway.

Documents that are written directly via the Couchbase SDK don’t have the required metadata, and can’t be replicated to mobile devices with Sync Gateway. If you want your documents to be mobile aware, they should be written to the bucket through the Sync Gateway REST API.


Hey, thanks for responding. Is this the Rest Api you are talking about ?


That’s the Couchbase Lite REST API. SG REST API docs are here:


ohhh i see, which one should i use? i am want to transfer my documents from my android phone in couchbase lite to the couch base server.

And do you have any working examples?


If you want to operate on documents on the Sync Gateway, from a server-side process, use the SG REST API.

If you have a mobile app written in JavaScript in a PhoneGap/Cordova/ReactNative container, use the Couchbase Lite REST API.

The two APIs are very similar as they both derive from the CouchDB API.

Yes, we have sample code posted on the website.


For the SG REST API,is GrocerySync an exmaple of that ?


No. Grocery Sync is a mobile app, so it uses the Couchbase Lite REST API.


ohhh, so that means if i need to use couchbase lite rest api because i am using my mobile phone to transfer data from couchbase lite to the couchbase server, Am i right '?


Your mobile application talks only to Couchbase Lite, using either the REST API (if it’s a JS app using PhoneGap or React Native), or the native APIs.

Couchbase Lite’s built-in replicator talks to Sync Gateway to sync data. You don’t have to worry about that or know how it’s done.

The only reason to use Sync Gateway’s REST API is if you are writing a server-side component (like an app server) that wants to view or modify documents in the database being managed by Sync Gateway.


okayyyyy thank you !!