locked
Unexpected character encountered while parsing value: <. Path '', line 0, position 0 RRS feed

  • Question

  • Hello,
    I am evaluating DocumentDB as backend for our new project and following MS Documentation, wrote a simple code.

       string uri = "xxxx";   string key = "xxxx";   ConnectionPolicy policy = new ConnectionPolicy();   policy.ConnectionMode = ConnectionMode.Gateway;   DocumentClient client = new DocumentClient(new Uri(uri), key,policy);                var dbresult = client.CreateDatabaseQuery().Where(a => a.Id == "DBID").AsEnumerable().FirstOrDefault();

    On the last line "CreateDatabaseQuery" I keep getting this weird exception "Newtonsoft.json error:Unexpected character encountered while parsing value: <. Path '', line 0, position 0"

    The frustating part is sometimes the same code block works but most of the time throws this error...

    The code is straight from Documentation,URI,key and database name are verified.Any clues what this could be?

    Already thinking maybe this thing is not yet stable!!

    Wednesday, January 13, 2016 6:15 AM

Answers

All replies

  • Unfortunately i am not able to reproduce this. 
    Could you please try the following and paste in your results.

    var dbs = client.ReadDatabaseFeedAsync();

    Monday, January 18, 2016 6:40 PM
  • Is this still an issue? 
    Thursday, February 4, 2016 2:33 AM
  • I'm getting the same issue.

    I don't get this error if I'm running any of the following operations through Web but getting error in Console App.

    DocumentDB operations:

    CreateDatabaseAsync

    CreateDocumentCollectionAsync

    CreateItemAsync

    I tried the same tutorial https://docs.microsoft.com/en-us/azure/documentdb/documentdb-get-started

    Issue is on single machine.

    Wednesday, April 5, 2017 4:18 PM
  • Getting the same exception when calling client.ReadDatabaseFeedAsync():

        let getOrCreateDatabase (client: DocumentClient) (databaseId: string) = async {
          let! dbs = client.ReadDatabaseFeedAsync() |> Async.AwaitTask
    
          let! rr = client.CreateDatabaseIfNotExistsAsync(new Database ( Id = databaseId )) |> Async.AwaitTask
          return rr.Resource
        }
       at Newtonsoft.Json.JsonTextReader.ParseValue()
       at Newtonsoft.Json.Linq.JObject.Load(JsonReader reader, JsonLoadSettings settings)
       at Microsoft.Azure.Documents.JsonSerializable.LoadFrom(JsonReader reader, JsonSerializerSettings serializerSettings)
       at Microsoft.Azure.Documents.JsonSerializable.LoadFrom[T](JsonTextReader jsonReader, ITypeResolver`1 typeResolver, JsonSerializerSettings settings)
       at Microsoft.Azure.Documents.Client.ClientExtensions.CreateDocumentClientException(HttpResponseMessage responseMessage)
       at Microsoft.Azure.Documents.Client.ClientExtensions.ParseResponseAsync(HttpResponseMessage responseMessage, JsonSerializerSettings serializerSettings)
       at Microsoft.Azure.Documents.GatewayStoreModel.<>c__DisplayClass20_0.<<InvokeAsync>b__0>d.MoveNext()
    --- End of stack trace from previous location where exception was thrown ---
       at Microsoft.Azure.Documents.BackoffRetryUtility`1.<>c__DisplayClass1_0.<<ExecuteAsync>b__0>d.MoveNext()
    --- End of stack trace from previous location where exception was thrown ---
       at Microsoft.Azure.Documents.BackoffRetryUtility`1.ExecuteRetryAsync(Func`1 callbackMethod, Func`3 callShouldRetry, Func`1 inBackoffAlternateCallbackMethod, TimeSpan minBackoffForInBackoffCallback, CancellationToken cancellationToken, Action`1 preRetryCallback)
       at Microsoft.Azure.Documents.ShouldRetryResult.ThrowIfDoneTrying(ExceptionDispatchInfo capturedException)
       at Microsoft.Azure.Documents.BackoffRetryUtility`1.ExecuteRetryAsync(Func`1 callbackMethod, Func`3 callShouldRetry, Func`1 inBackoffAlternateCallbackMethod, TimeSpan minBackoffForInBackoffCallback, CancellationToken cancellationToken, Action`1 preRetryCallback)
       at Microsoft.Azure.Documents.BackoffRetryUtility`1.ExecuteAsync(Func`1 callbackMethod, IRetryPolicy retryPolicy, CancellationToken cancellationToken, Action`1 preRetryCallback)
       at Microsoft.Azure.Documents.GatewayStoreModel.InvokeAsync(DocumentServiceRequest request, ResourceType resourceType, CancellationToken cancellationToken)
       at Microsoft.Azure.Documents.GatewayStoreModel.ProcessMessageAsync(DocumentServiceRequest request, CancellationToken cancellationToken)
       at Microsoft.Azure.Documents.Client.DocumentClient.ReadFeedAsync(DocumentServiceRequest request, CancellationToken cancellationToken)
       at Microsoft.Azure.Documents.Query.DocumentQueryClient.ReadFeedAsync(DocumentServiceRequest request, CancellationToken cancellationToken)
       at Microsoft.Azure.Documents.Query.DocumentQueryExecutionContextBase.ExecuteReadFeedRequestAsync(DocumentServiceRequest request, CancellationToken cancellationToken)
       at Microsoft.Azure.Documents.Query.DocumentQueryExecutionContextBase.ExecuteRequestAsync(DocumentServiceRequest request, CancellationToken cancellationToken)
       at Microsoft.Azure.Documents.Query.DefaultDocumentQueryExecutionContext.ExecuteOnceAsync(IDocumentClientRetryPolicy retryPolicyInstance, CancellationToken cancellationToken)
       at Microsoft.Azure.Documents.Query.DefaultDocumentQueryExecutionContext.<>c__DisplayClass9_0.<<ExecuteInternalAsync>b__0>d.MoveNext()
    --- End of stack trace from previous location where exception was thrown ---
       at Microsoft.Azure.Documents.BackoffRetryUtility`1.<>c__DisplayClass1_0.<<ExecuteAsync>b__0>d.MoveNext()
    --- End of stack trace from previous location where exception was thrown ---
       at Microsoft.Azure.Documents.BackoffRetryUtility`1.ExecuteRetryAsync(Func`1 callbackMethod, Func`3 callShouldRetry, Func`1 inBackoffAlternateCallbackMethod, TimeSpan minBackoffForInBackoffCallback, CancellationToken cancellationToken, Action`1 preRetryCallback)
       at Microsoft.Azure.Documents.ShouldRetryResult.ThrowIfDoneTrying(ExceptionDispatchInfo capturedException)
       at Microsoft.Azure.Documents.BackoffRetryUtility`1.ExecuteRetryAsync(Func`1 callbackMethod, Func`3 callShouldRetry, Func`1 inBackoffAlternateCallbackMethod, TimeSpan minBackoffForInBackoffCallback, CancellationToken cancellationToken, Action`1 preRetryCallback)
       at Microsoft.Azure.Documents.BackoffRetryUtility`1.ExecuteAsync(Func`1 callbackMethod, IRetryPolicy retryPolicy, CancellationToken cancellationToken, Action`1 preRetryCallback)
       at Microsoft.Azure.Documents.Query.DefaultDocumentQueryExecutionContext.ExecuteInternalAsync(CancellationToken cancellationToken)
       at Microsoft.Azure.Documents.Query.DocumentQueryExecutionContextBase.ExecuteNextAsync(CancellationToken cancellationToken)
       at Microsoft.Azure.Documents.Query.ProxyDocumentQueryExecutionContext.ExecuteNextAsync(CancellationToken token)
       at Microsoft.Azure.Documents.Linq.DocumentQuery`1.ExecuteNextPrivateAsync[TResponse](CancellationToken cancellationToken)
       at Microsoft.Azure.Documents.Client.ResourceFeedReader`1.ExecuteNextAsyncInternal(CancellationToken cancellationToken)
       at Microsoft.Azure.Documents.Client.DocumentClient.ReadDatabaseFeedPrivateAsync(FeedOptions options, IDocumentClientRetryPolicy retryPolicyInstance)
       at Microsoft.Azure.Documents.BackoffRetryUtility`1.<>c__DisplayClass1_0.<<ExecuteAsync>b__0>d.MoveNext()
    --- End of stack trace from previous location where exception was thrown ---
       at Microsoft.Azure.Documents.BackoffRetryUtility`1.ExecuteRetryAsync(Func`1 callbackMethod, Func`3 callShouldRetry, Func`1 inBackoffAlternateCallbackMethod, TimeSpan minBackoffForInBackoffCallback, CancellationToken cancellationToken, Action`1 preRetryCallback)
       at Microsoft.Azure.Documents.ShouldRetryResult.ThrowIfDoneTrying(ExceptionDispatchInfo capturedException)
       at Microsoft.Azure.Documents.BackoffRetryUtility`1.ExecuteRetryAsync(Func`1 callbackMethod, Func`3 callShouldRetry, Func`1 inBackoffAlternateCallbackMethod, TimeSpan minBackoffForInBackoffCallback, CancellationToken cancellationToken, Action`1 preRetryCallback)
       at Microsoft.Azure.Documents.BackoffRetryUtility`1.ExecuteAsync(Func`1 callbackMethod, IRetryPolicy retryPolicy, CancellationToken cancellationToken, Action`1 preRetryCallback)
    I'm trying to use the azure-cosmosdb-emulator and have no idea why I can't create a new collection...

    Monday, November 5, 2018 1:22 PM