N1QL Rest API Probelm with port 8093

#1

Hi there, i’m new to N1QL. i have done one Application by using Couchbase Lite in iOS. Now i want to access my data on Admin Portal. so i want to create a Public Rest API by using N1QL queries.

I Read this tutorial. but im not able to execute following GET request on Postman.

http://myaddress:8093//query?statement=SELECT%20*%20from%20default%20limit%201

have i to do any configuration for executing N1QL queries on my server for Public Rest API.

Any one please help me on this. it will help to me a lot.

Thanks in advance.
Srinadh

#2

Hi Srinadh,

Looks like a typo in the URL you are using. It should be http://myaddress:8093/query/service, not http://myaddress:8093//query, so the full thing would be

http://myaddress:8093/query/service?statement=SELECT%20*%20from%20default%20limit%201

Does that one work for you?

#3

Hi @JFlath, Thanks for reply. still I’m facing issue, following is the link im using.

here default is my bucket name

http://myurl.com:8093/query/service?statement=SELECT%20*%20from%20default%20limit%201

#4

Hmm. Are you able to use the REST API with curl?
e.g.:

$ curl -v http://host:8093/query/service -d "statement=select * from default"

I’m not too familiar with how Postman displays error messages, but curl should shed some light on it. Are you sure the machine you’re on can reach the Couchbase Server node? How about if you just try to hit one of the other ports on the node, e.g:

$ curl -v http://localhost:8092
* Rebuilt URL to: http://localhost:8092/
*   Trying 127.0.0.1...
* Connected to localhost (127.0.0.1) port 8092 (#0)
> GET / HTTP/1.1
> Host: localhost:8092
> User-Agent: curl/7.43.0
> Accept: */*
> 
< HTTP/1.1 200 OK
< Server: MochiWeb/1.0 (Any of you quaids got a smint?)
< Date: Mon, 02 May 2016 13:56:18 GMT
< Content-Type: text/plain;charset=utf-8
< Content-Length: 90
< Cache-Control: must-revalidate
< 
{"couchdb":"Welcome","version":"2.1.1r-545-g29c7ee6","couchbase":"4.5.0-1308-enterprise"}
* Connection #0 to host localhost left intact
#5

@JFlath sorry i didn’t try curl. but i tried to test curl operation for testing port. it was failed see below image For more details. How can i up 8092 port.

#6

Hi,

8091 : Is the admin port
8093 : Is the query port

A possible reason that you get the above error with the Postman app is that your couchbase instance isn’t running, or you havent pointed it to the correct URL.

Try the following curl command (after replacing my host to your hostname or ip):
curl -v http://myhost:8093/query/service -d ‘statement=select 1’

You could also try the following command :
curl -v http://myhost:8091/pools

If these curl commands work, then we can debug further as to why you aren’t able to connect.

Thanks

#7

As Isha said, you can also try connecting to 8091 or 8093 to check connectivity - I just happened to pick 8092 as an example. When you ran the curl command in the screenshot, were you on one of the Couchbase Server nodes? If not, you would need to use the hostname of one of them instead of localhost as in my example.

So in your case I that would be curl -v http://myappdemo.com:8092, or you could use the examples Isha mentioned, either’s good.

#8

@isha, Thanks for your reply. yes 8091 Admin port working instead of 8093 query port. Hey how can i run this on my postman for public Rest Api too.

if i want to run on query port. what should i do?

#9

@JFlath Thanks, yes as Isha said, its working on Admin port. but not on query port. what should i do, for working on query port? is it possible to run on Public API.

#10

Hi Srinadh,

Can you post the output of the curl command for 8093 here ?

Try the following curl command (after replacing my host to your hostname or ip):
curl -v http://myhost:8093/query/service -d ‘statement=select 1’

Also what services have you enabled in your couchbase instance ?

Thanks
Isha

#11

Hi @isha,

Im getting following result when i try you suggested query.

How can i check what services was enabled in couchbase instance.

Thanks,
Srinadh

#12

If you go to the admin ui and click on the Server Nodes tab, for each server you will see a list of services. Does that contain query ?

Thanks
Isha

#13

Here is result of Server Nodes tab. how can i activate 8093 query port. why its not working under my server.