Microsoft.Azure.Documents.DocumentClientException:服务器无法解析 Url
Microsoft.Azure.Documents.DocumentClientException: Server could not parse the Url
我正在为 .Net 使用 1.4.1 版的 DocumentDB 客户端,当我尝试更新集合中的文档时出现此错误:
DocumentClientException: Server could not parse the Url.
当我这样做时:
await _repository.Client.ReplaceDocumentAsync(DocumentsLink, document);
其中 Client 是 DocumentClient,DocumentsLink 是路径 dbs/9TBhAA==/colls/9TBhANQ4yAA=/docs/
的 URI
这样构造的:
public Uri DocumentsLink
{
get
{
if (string.IsNullOrEmpty(_documentsLink))
{
_documentsLink = _repository.Collection.DocumentsLink;
}
return new Uri(_documentsLink, UriKind.Relative);
}
}
并记录一个简单的 json 文档。
此代码在同一数据库的不同集合上运行良好。
如果我使用 linq 扩展并传递一个字符串而不是相对 URI,我会得到同样的错误。
有人对如何解决这个问题有指点吗?
这很奇怪;您确定这适用于同一数据库中的不同集合吗?
ReplaceDocumentAsync()
需要特定文档的完整路径。路径 dbs/9TBhAA==/colls/9TBhANQ4yAA=/docs/
仅解析为一个集合。
您需要附加删除文件 - 看起来像这样:dbs/UtJlAA==/colls/UtJlAKU5IAE=/docs/UtJlAKU5IAELAAAAAAAAAA==/
我正在为 .Net 使用 1.4.1 版的 DocumentDB 客户端,当我尝试更新集合中的文档时出现此错误:
DocumentClientException: Server could not parse the Url.
当我这样做时:
await _repository.Client.ReplaceDocumentAsync(DocumentsLink, document);
其中 Client 是 DocumentClient,DocumentsLink 是路径 dbs/9TBhAA==/colls/9TBhANQ4yAA=/docs/
的 URI这样构造的:
public Uri DocumentsLink
{
get
{
if (string.IsNullOrEmpty(_documentsLink))
{
_documentsLink = _repository.Collection.DocumentsLink;
}
return new Uri(_documentsLink, UriKind.Relative);
}
}
并记录一个简单的 json 文档。
此代码在同一数据库的不同集合上运行良好。
如果我使用 linq 扩展并传递一个字符串而不是相对 URI,我会得到同样的错误。
有人对如何解决这个问题有指点吗?
这很奇怪;您确定这适用于同一数据库中的不同集合吗?
ReplaceDocumentAsync()
需要特定文档的完整路径。路径 dbs/9TBhAA==/colls/9TBhANQ4yAA=/docs/
仅解析为一个集合。
您需要附加删除文件 - 看起来像这样:dbs/UtJlAA==/colls/UtJlAKU5IAE=/docs/UtJlAKU5IAELAAAAAAAAAA==/