【问题标题】:Azure DocumentDb API newtonsoft parser errorAzure DocumentDb API newtonsoft 解析器错误
【发布时间】:2018-10-26 13:27:45
【问题描述】:

我正在尝试连接到 Azure Cosmos DB。我只是按照微软的教程,但我不会工作。

client = new DocumentClient(new Uri ("<MY ENDPOINT>"),"<MY KEY>");

这似乎可行,但是当我尝试在数据库中执行任何操作时,它不断抛出 Json Parser 异常。

await this.client.CreateDatabaseIfNotExistsAsync(new Database { Id = "DynamicForms" });

它会引发以下错误。我不知道是我做错了什么还是真的是一个错误。

在 Newtonsoft.Json.JsonTextReader.ParseValue()\r\n
在 Newtonsoft.Json.JsonTextReader.Read()\r\n
在 Newtonsoft.Json.Linq.JObject.Load(JsonReader 阅读器,JsonLoadSettings 设置)\r\n
在 Microsoft.Azure.Documents.JsonSerializable.LoadFrom(JsonReader 阅读器,JsonSerializerSettings serializerSettings)\r\n
在 Microsoft.Azure.Documents.JsonSerializable.LoadFrom[T](JsonTextReader jsonReader, ITypeResolver1 typeResolver, JsonSerializerSettings settings)\r\n
at Microsoft.Azure.Documents.Client.ClientExtensions.CreateDocumentClientException(HttpResponseMessage responseMessage)\r\n
at Microsoft.Azure.Documents.Client.ClientExtensions.ParseResponseAsync(HttpResponseMessage responseMessage, JsonSerializerSettings serializerSettings)\r\n
at Microsoft.Azure.Documents.Client.GatewayServiceConfigurationReader.GetDatabaseAccountAsync(Uri serviceEndpoint)\r\n
at Microsoft.Azure.Documents.Routing.GlobalEndpointManager.GetDatabaseAccountFromAnyLocationsAsync(Uri defaultEndpoint, IList
1 个位置, Func2 getDatabaseAccountFn)\r\n
at Microsoft.Azure.Documents.Client.GatewayServiceConfigurationReader.InitializeReaderAsync()\r\n
at Microsoft.Azure.Documents.Client.DocumentClient.InitializeGatewayConfigurationReader()\r\n
at Microsoft.Azure.Documents.Client.DocumentClient.GetInitializationTask()\r\n
at Microsoft.Azure.Documents.Client.DocumentClient.EnsureValidClientAsync()\r\n
at Microsoft.Azure.Documents.Client.DocumentClient.ReadDatabasePrivateAsync(String databaseLink, RequestOptions options, IDocumentClientRetryPolicy retryPolicyInstance)\r\n
at Microsoft.Azure.Documents.BackoffRetryUtility
1.c__DisplayClass1_0.d.MoveNext()\r\n--- End来自先前引发异常的位置的堆栈跟踪 ---\r\n
在 Microsoft.Azure.Documents.BackoffRetryUtility1.ExecuteRetryAsync(Func1 callbackMethod, Func3 callShouldRetry, Func1 inBackoffAlternateCallbackMethod, TimeSpan minBackoffForInBackoffCallback, CancellationToken cancelToken, Action1 preRetryCallback)\r\n
at Microsoft.Azure.Documents.ShouldRetryResult.ThrowIfDoneTrying(ExceptionDispatchInfo capturedException)\r\n
at Microsoft.Azure.Documents.BackoffRetryUtility
1.ExecuteRetryAsync(Func1 callbackMethod, Func3 callShouldRetry, Func@98765432 r\n
在 Microsoft.Azure.Documents.BackoffRetryUtility1.ExecuteAsync(Func1 callbackMethod, IRetryPolicy retryPolicy, CancellationToken cancelToken, Action`1 preRetryCallback)\r\n
在 Microsoft.Azure.Documents.Client.DocumentClient.CreateDatabaseIfNotExistsPrivateAsync(数据库数据库,RequestOptions 选项)\r\n
在 D:\Projetos\DynaForms\POCVueNetCoreMongo\Data\Connector.cs:line 29 中的 POCVueNetCoreMongo.Connector.GenerateStructureAsync() 处

【问题讨论】:

  • 只是一个评论,据我所知,您的代码是正确的。这直接来自文档: using (IDocumentClient client = new DocumentClient(new Uri("service endpoint"), "auth key")) { Database db = client.CreateDatabaseIfNotExistsAsync(new Database { Id = "MyDatabase" }).Result ; }
  • @Trey 如果我在类的构造函数上使用 using sn-p 或实例化客户端对象没有区别
  • 我不确定是什么问题,我会联系他们的支持。

标签: c# json.net azure-cosmosdb


【解决方案1】:

这是公司代理问题。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2017-10-07
    • 1970-01-01
    • 1970-01-01
    • 2014-05-20
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多