DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
Refcards Trend Reports Events Over 2 million developers have joined DZone. Join Today! Thanks for visiting DZone today,
Edit Profile Manage Email Subscriptions Moderation Admin Console How to Post to DZone Article Submission Guidelines
View Profile
Sign Out
Refcards
Trend Reports
Events
Zones
Culture and Methodologies Agile Career Development Methodologies Team Management
Data Engineering AI/ML Big Data Data Databases IoT
Software Design and Architecture Cloud Architecture Containers Integration Microservices Performance Security
Coding Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Partner Zones AWS Cloud
by AWS Developer Relations
Culture and Methodologies
Agile Career Development Methodologies Team Management
Data Engineering
AI/ML Big Data Data Databases IoT
Software Design and Architecture
Cloud Architecture Containers Integration Microservices Performance Security
Coding
Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance
Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Partner Zones
AWS Cloud
by AWS Developer Relations
Content provided by Couchbase logo

Querying Couchbase Sync Gateway Using Postman

Learn how to install Couchbase Sync Gateway and Postman, and the couple of steps that are required to use Postman to query the Couchbase Sync Gateway.

Priya Rajagopal user avatar by
Priya Rajagopal
·
May. 14, 17 · Tutorial
Like (2)
Save
Tweet
Share
3.15K Views

this post discusses a convenient way to query, explore, and test the rest api exposed by the couchbase mobile sync gateway using the postman chrome developer tool. sync gateway exposes a rest, batch and stream interface that allows clients interact with it over the internet.

note: we will be discussing couchbase mobile v1.4 which is the current production release. there is a newer developer preview version 2.0 of couchbase mobile.

background

couchbase sync gateway is part of the couchbase mobile stack and is an internet-facing synchronization mechanism that securely syncs data across devices as well as between devices and the cloud. there are two ports over which the sync gateway listens to requests: the admin port (defaults to 4985 ) and the public port (defaults to 4984 ). in production deployments, the admin port is typically blocked from access over the internet.

installation of couchbase sync gateway

please follow instructions in the blog post to install the sync gateway in your mac os development environment. see the downloads site for all the available packages and see the full installation guide for complete details. to install on linux distributions other than the supported ones, see this post .

installation of postman

postman is a chrome developer tool that can be downloaded for free from the chrome browser web store .

using postman to query the couchbase sync gateway

here's how to use postman to query the couchbase sync gateway.

get the postman collections

the postman collection files and environment definition for the admin and public interface of the sync gateway are available for download from this github repo .

git clone git@github.com:couchbaselabs/syncgateway-postman-collection.git

there should be three files:

  1. sync-gateway-admin.postman_collection : this is the portman collection corresponding to the admin interface of the sync gateway.

  2. sync-gateway-public.postman_collection : this is the portman collection corresponding to the public interface of the sync gateway.

  3. sync-gateway-environment.postman_environment : this is the environment definitions file that defines the variables used by the admin and public collections.

launch the postman app

launching the postman app requires a couple of steps.

import the collections

follow the steps in the video below to import the collections that were downloaded in the previous step.

importing sync gateway postman collections.

import the environment file

follow the steps in below to import the environment definition corresponding to the postman collections:

importing the environment definition for admin and public interfaces.

set the appropriate environment

follow the steps in the video below to set the environment to the one that you just imported. update the values of the variables to suit your environment. make sure that the adminurl points to the sync gateway at admin port and the publicurl variable points to the sync gateway at the public port. it defaults to http://localhost:4985 and http://localhost:4984 respectively.

setting the postman environment.

that’s it! run your queries

the following is a demonstration of running a request on the admin interface:

querying the admin interface of sync gateway.

the following is a demonstration of running a request on the public interface. make sure you set the authorization header is set appropriately to use the appropriate authentication mechanism.

querying the public interface of sync gateway.

cli option

if you are interested in executing the postman collection from the command line interface, which may be the case for instance, if you want to integrate this as part of your continuous integration process, then you should check out newman , which is cli runner for postman.

for example, the command below will run the sync-gateway-admin.postman_collection with the sync-gateway-environment file.

if your sync gateway is running with ssl enabled and is using a self-signed certificate, the “-k” option will suppress validation of the cert (“insecure” ssl connection). this is not recommended in production environments.

newman run -k  sync-gateway-admin.postman_collection --environment sync-gateway-environment.postman_environment --bail --delay-request 300;

next steps

the postman collections provide an easy way to query, explore and test the rest interface exposed by the sync gateway. if you see an issue in the collections definitions or if you would like to enhance it, please submit a pull request to the github repo .


Comments

ABOUT US

  • About DZone
  • Send feedback
  • Careers
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 600 Park Offices Drive
  • Suite 300
  • Durham, NC 27709
  • support@dzone.com

Let's be friends: