Accessing documents using sync_gateway REST API


#1

Could someone please tell me how to GET a particular document using the sync gateway REST APIs? I tried GET “localhost:4984/{dbname}/{doc_id}” for which I get a reply

{"error":"Forbidden","reason":"forbidden"}

when I tried GET on "localhost:4985/{dbname}/{doc_id} I get a response

[Fiddler] The connection to 'localhost' failed. <br />Error: ConnectionRefused (0x274d). <br />System.Net.Sockets.SocketException No connection could be made because the target machine actively refused it localhost:4985    

What am I doing wrong?

EDIT: Ok so I realised why the call to port 4985 doesn’t work. Sync gateway’s admin rest api’s are behind a firewall and only work from localhost. But why doesn’t the call to 4984 work?


#2

Looks like you haven’t set up access to your documents. Have you created any users? If you haven’t and guest access is also disabled then almost no request to 4984 will succeed. What does your sync gateway config file look like?


#3

Hello @Abhilash,

Adding to @borrrden answer above, I am able to localhost:4984 in after having my config.json file users property be:

  "users": {
    "GUEST": {"disabled": false}
  },  

Make sure you are referencing the correct database too within your .JSON file.