In-browser and online tutorial query issues

Hi,

The tutorial at http://query.pub.couchbase.com/tutorial/ does not appear to be working properly for N1QL DP 4.

Thanks.

After having installed N1QL DP4 I similarly see the same error messages, with 500 HTTP Internal Server Error codes, 5000 N1QL/Couchbase error codes and the message:

“Either statement or prepared must be provided.”

This is true for all queries I make, so right now I can’t get it to work.

Note: the startup call I give is:

./cbq-engine -datastore http://localhost:8091/

And I get the following responses:

_time=“2015-01-14T07:54:42-04:00” _level=“INFO” _msg=“New site created with url http://localhost:8091/
_time=“2015-01-14T07:54:42-04:00” _level=“INFO” _msg=“cbq-engine started” version=“cbq-dp4” datastore=“http://localhost:8091/

I can also view the tutorial in the browser, and Couchbase is up and running.

The same is true is ./start_tutorial.sh is used, so it appears that it’s an N1QL issue.

Note: I can run queries using ./cbq, it’s when running the tutorial in a browser (and performing HTTP REST requests to http://server:8093/query) that there are issues.

Any ideas of what I should do?

Thanks.

I think I’ve found the problem / solution. When performing the HTTP request, the following header needs to be set:

Content-Type: text/plain

e.g. When using curl, the following command succeeds:

curl -d ‘select * from tutorial’ -H ‘Content-Type: text/plain’ localhost:8093/query

but the following fails:

curl -d ‘select * from tutorial’ localhost:8093/query

This is set automatically with cbq, but in the tutorial, it’s URL-encoded, and starts like q=…, which I’m assuming no longer works.

Hi Eugaia,

Please try the following:

(1) Run start_tutorial, which will start cbq-engine:

./start_tutorial.sh

(2) Run a HTTP request using curl:

curl -d ‘statement=select * from tutorial’ localhost:8093/query

The N1QL query must be the value of a HTTP request parameter called ‘statement’. For more info on using the HTTP API, please take a look at http://docs.couchbase.com/prebuilt/n1ql/n1ql-dp4/N1QLRef-DP4.pdf, specifically Chapter 14, “REST API”. Also please don’t hesitate to follow-up with any further questions or comments.

Thanks,
Colm.

Hi,

Yes, that worked for me as well - and now both the tutorial interface on my home system and the online tutorial are working. I’m not sure what it was that was causing the issue, but it appears to have been fixed by a restart. Most puzzling.

Thanks for the follow-up.