1
votes

Having an error with a remote IBM Cloudant database replication. I'm using "pouchdb": "^7.2.1" in an Angular 8 app with TypeScript. The weirdest thing is that sometimes it works and sometimes not. When it's not, it says:

CustomPouchError {error: "bad_request", reason: "Please supply either IAM session cookie or basic auth not both", status: 400, name: "bad_request", message: "Please supply either IAM session cookie or basic auth not both", …}
error: "bad_request"
reason: "Please supply either IAM session cookie or basic auth not both"
status: 400
name: "bad_request"
...

The code used to replicate from remote DB is straight forward:

private startReplication(localDB: PouchDB.Database, remoteDB: PouchDB.Database):Promise<PouchDB.Database> {
    return new Promise((resolve, reject) => {
      let replicationHandler = localDB.replicate
        .from(remoteDB, {
          batch_size: 200,
          batches_limit: 10
        })
        .on("paused", info => {
          replicationHandler.cancel()
        })
        .on("complete", info => {
          replicationHandler.cancel()
          resolve()
        })
        .on("error", err => {
          replicationHandler.cancel()
          reject(err)
        })
    })
  }

Remote DB is defined like this:

let userDB = "https://token:[email protected]/mydatabase$username"
this.remoteDB = new PouchDB(`${userDB}`, {
      auto_compaction: true
    })
1

1 Answers

0
votes

It seems like the Cloudant server thinks you're making a request using both basic auth and an IAM session cookie, which it rejects. Maybe try clearing your Cloudant cookies?