1

I'm sending a POST request to add Document to Couchbase Server via Sync Gateway Server. I'm using serviceconfig.json, similar to link. server key in "databases" contains a link to my Couchbase Server (http://localhost:8091). While firing the POST request, it shows a response shown below. Also, I have added the logs below,

404 no such database "fineract-cn"
400 invalid database name "favicon.ico"

enter image description here

Matthew Groves
  • 25,181
  • 9
  • 71
  • 121
miPlodder
  • 795
  • 8
  • 18
  • 1
    Share your sync gateway config. Prior to that, (a) check the [database](https://docs.couchbase.com/sync-gateway/2.5/config-properties.html#databases) section in your sync gateway config file and ensure that you have configured the right database and (b) confirm that the Sync Gateway database is pointing to the right bucket on couchbase server. – rajagp Aug 15 '19 at 19:53
  • 1
    Can you the serviceconfig.json (https://pastebin.com/G7BWpeBy). Yeah, I check the (a) and (b). Still, I'm sending you some details to cross-check. My Sync Gateway database name is `fineract-cn`. My Bucket name on Couchbase is `fineract-cn`. My RBAC credentials are `admin` and `password` and I have given access. – miPlodder Aug 16 '19 at 00:47
  • 1
    When I keep a basic `serviceconfig.json` file, I'm able to add to Sync Gateway Server. But when I give this (https://pastebin.com/G7BWpeBy) file, I'm not able to add to Sync Gateway also. Can you check, and let me know if you need any more detail ? – miPlodder Aug 16 '19 at 00:49
  • 1
    You are using a config file that is written for a particular application - the users, sync function are specific to that use case. Changing params ad-hoc isn't best approach. I would encourage you to familiarize yourself with the fundamentals of [sync function](https://docs.couchbase.com/sync-gateway/2.5/sync-function-api.html) and follow this [simple tutorial](https://docs.couchbase.com/userprofile-couchbase-mobile/sync/userprofile/android/userprofile_sync.html). SGW config for typical usage patterns are available [here](https://github.com/couchbase/sync_gateway/tree/master/examples) – rajagp Aug 17 '19 at 16:19
  • It's working now. Shouldn't Sync Gateway clean all Document when it's added to the Couchbase Server? – miPlodder Aug 18 '19 at 11:56
  • What do you mean by "clean" document ? – rajagp Aug 19 '19 at 12:50
  • For example, I add a Document from my Android Application which adds the Document to the Sync Gateway Server and it forwards it to the Couchbase Server. By `clean`, I mean, shouldn't Sync Gateway clean the document as its added to the Couchbase Server? – miPlodder Aug 20 '19 at 15:25
  • Moreover, my Android Application is caching up the Documents on the mobile device. For eg, if I restart the Sync Gateway Server, there are no Documents in the Sync Gateway Server. Now, when I make one more Document Push from my mobile application. It adds the previous Document to Sync Gateway Server. How do I stop this behavior from my Android device? – miPlodder Aug 20 '19 at 15:52
  • 1
    This seems completely unrelated than the original issue (which I believe is resolved). I would suggest opening a separate question and tracking it there. – rajagp Aug 20 '19 at 18:56
  • Ok, will do that – miPlodder Aug 22 '19 at 04:19
  • Hey @miPlodder: can you accept the (correct) answer, below, so that others can find it? – G. Blake Meike Sep 04 '19 at 18:15

1 Answers1

1

The response indicate you are not posting a doc with a proper user authentication. You need firstly create a session with username/password:

https://docs.couchbase.com/sync-gateway/2.1/rest-api.html#/session/post__db___session

the POST session request will return a cookie and a session id, in your _bulk_docs, you need to attach the cookie in your POST request.