2
votes

I'm using the 1.4.1 version of DocumentDB client for .Net and when I try to update a document in the collection I get this error:

DocumentClientException: Server could not parse the Url.

When I do:

await _repository.Client.ReplaceDocumentAsync(DocumentsLink, document);

where Client is a DocumentClient and DocumentsLink is an URI for path dbs/9TBhAA==/colls/9TBhANQ4yAA=/docs/

constructed this way:

public Uri DocumentsLink
{
    get
    {
        if (string.IsNullOrEmpty(_documentsLink))
        {
            _documentsLink = _repository.Collection.DocumentsLink;
        }
        return new Uri(_documentsLink, UriKind.Relative);
    }
}

and document a simple json doc.

This code has been working fine on a different collection on the same database.

I get the same error if I use the linq extension and pass a string instead of a relative URI.

Anyone has pointers on how to resolve this issue?

1
Is the uri really adbs/9TBhAA==/colls/9TBhAPqqYgE=/docs/? It shouldn't start with a. - David Makogon
Indeed it's a typo in the question, I'm adjusting the question - Étienne Brouillard

1 Answers

2
votes

That's odd; are you sure this worked on a different collection in the same database?

ReplaceDocumentAsync() requires a full path to a specific document. The path, dbs/9TBhAA==/colls/9TBhANQ4yAA=/docs/, only resolves to a collection.

You need to append the rid of the document - which will look something like this: dbs/UtJlAA==/colls/UtJlAKU5IAE=/docs/UtJlAKU5IAELAAAAAAAAAA==/