"No statement or prepared value" error when execute PREPARE statement

I am using Couchbase Server 4.1.0-5005 Enterprise Edition (build-5005)
and when I execute a PREPARE statement, it return:

*   Trying 127.0.0.1...
* Connected to 127.0.0.1 (127.0.0.1) port 8093 (#0)
> POST /query/service HTTP/1.1
> Host: 127.0.0.1:8093
> User-Agent: curl/7.43.0
> Accept: */*
> Content-Length: 908
> Content-Type: application/x-www-form-urlencoded
>
* upload completely sent off: 908 out of 908 bytes
< HTTP/1.1 400 Bad Request
< Content-Length: 377
< Content-Type: application/json; version=1.0.0
< Date: Sat, 13 Feb 2016 07:54:06 GMT
<
{
    "requestID": "370fa8a4-972e-4170-8562-ab58632280b4",
    "errors": [
        {
**            "code": 1050,**
**            "msg": "No statement or prepared value"**
        }
    ],
    "status": "fatal",
    "metrics": {
        "elapsedTime": "88.514µs",
        "executionTime": "87.975µs",
        "resultCount": 0,
        "resultSize": 0,
        "errorCount": 1
    }
}
* Connection #0 to host 127.0.0.1 left intact

My PREPARE statement looks like:

curl -v http://127.0.0.1:8093/query/service -d 'statement=PREPARE myprepquery FROM **{my N1QL}** '

the ** {my N1QL}** in cbq works fine(replace parameter with the real value).
My other PREPARE statement works fine.
Is this cause by long request parameter (Content-Length: 908)?

Do you actually have the double asterisk ** in your curl command?

No, It for Strong the text.

Ok. Can you please post the full PREPARE that works, and the one that doesn’t work, so we can compare them? Thanks.

OK, Please notice your message.

The solution is to use url-encode the argument to curl. Instead of

curl -d ...

use

curl --data-urlencode ...

Thank you very much, It works.

1 Like