QueryRequest error - Unexpected character encountered while parsing value


I’m trying to run a simple QueryRequest but I keep seeing the following error:
{“Unexpected character encountered while parsing value: <. Path ‘’, line 0, position 0.”}

Here is the code I’m using to produce this:

// create my bucket using a helper
var bucket = CouchbaseManager.Instance.GetBucket("MyBucket");

// simple test to verify my connection is working
var test = bucket.GetDocument<string>("1");

// create query request
var queryRequest = new QueryRequest().Statement("SELECT * FROM 'MyBucket' LIMIT 10");
var results = bucket.Query<dynamic>(queryRequest);

Interestingly, results.Status is Success and both errors and warnings collection are empty. However, if I look at Success property; it reports false. Also the exception reads as above.

The one unique angle is that I’m using my own Json serializer. So whenever data goes into couchbase, it looks uses this:

public static string Serialize<TValue>(TValue value) where TValue : class
         var ms = new MemoryStream();
         var serializer = new DataContractJsonSerializer(typeof(TValue));

         serializer.WriteObject(ms, value);
         var json = Encoding.Default.GetString(ms.ToArray());

         return json;

I’m guessing query request may be trying to use its own deserializer and not respecting my DataContractJsonSerializer. I tried to use bucket.Query<string> and bucket.Query<object> to see if I could work around this.

Anyone have any suggestions?



Hi @becker,
From your query it looks like you are using a wrong single quote character to escape the bucket name.

Here are a few samples that are build to copy/paste for testing and learning. Please note the special single quote character used to escape bucket names.

I hope this helps.