Couchbase Lite _replicate 400 BAD REQUEST with Cordova (PhoneGap) and Ionic Framework (AngularJS) javascript $http on iOS

I cannot get Coucbase Lite _replicate to work with Cordova (PhoneGap), using the Ionic Framework (AngularJS) and $http call. $http always results in a 400 BAD REQUEST from Couchbase Lite. I’m uncertain about the proper config settings, nor how to debug the error at a deeper level (yet).

Due to my existing codebase, I want to use $http.post with Couchbase Lite. My Couchbase server and Sync Gateway are working together fine and are configured to use bucket shadowing between the sync bucket and primary server bucket.

DETAILS:

CBL ERROR REASON: {“data”:{“status”:400,“error”:“bad_request”},“status”:400,“config”:{“method”:“POST”,“transformRequest”:[null],“transformResponse”:[null],“url”:“http://lite.couchbase./_replicate”,“data”:{“target”:”app-cbl",“source”:“10.60.0.100/sync_gateway/”,“continuous”:“true”},“contentType”:“application/json”,“headers”:{“Accept”:“application/json, text/plain, /”,“Content-Type”:“application/json;charset=utf-8”}},“statusText”:"Bad Request”}

//
// Cordova code running on iOS
//
this.startReplication = function () {
var deferred = $q.defer();

// -- I have tried multiple configs, using both $http and $http.post, and also revised source / target --
// -- This config is the closest to working, but results in a 400 error. --
var config = {
    method: 'POST',
    url: "http://lite.couchbase./_replicate",
    data: {
        target: ’app-cbl’,
        source: ’10.60.0.100/sync_gateway/',
        continuous: 'true'
    },
    contentType: 'application/json'
}

$http(config).then(function (result) {
    console.log('### CBL SUCCESS RESULT: ' + JSON.stringify(result));
    deferred.resolve(result);
}, function (reason) {
    console.log('### CBL ERROR REASON: ' + JSON.stringify(reason));
    deferred.reject(reason);
}).catch(function (err) {
    console.log('### CBL CATCH ERROR: ' + JSON.stringify(err));
    deferred.reject(err);
})
return deferred.promise;
}

I have also tried different URLs for the sync gateway, but still get the same 400 error so I assume the error is originating locally on the iOS side.

Thank you for any assistance.

Thanks to @jens answer on the Google Groups thread.
https://groups.google.com/forum/#!topic/mobile-couchbase/y7Lio2PuZ78

Resolution:

  1. continuous should be true (as a boolean), not “true” (as a string)
  2. source missing protocol (http://)