1
votes

I have the following F# code attempting to get a user document from my documentdb database and it doesn't work. Is anyone else experiencing problems using the ReadDocumentAsync method? I am able to successfully to query my user documents with the CreateDocumentQuery method. Any help is greatly appreciated. I use my database and collection ids in place of the empty strings in the code snippet

let getUserDatabaseModel (documentClient : DocumentClient) originiatorId =
    async {
        let databaseId = ""
        let collectionId = ""
        let documentUri = UriFactory.CreateDocumentUri(databaseId, collectionId, originiatorId)

        let! userDatabaseModel = 
            documentClient.ReadDocumentAsync(documentUri)
                |> Async.AwaitTask


        return userDatabaseModel
    }
      |> Async.RunSynchronously

Update If I use the _rid instead of the id I get the data back. To clarify the ReadDocumentAsync seems to work using the _rid but throws the error below when using the id.

mscorlib: Exception has been thrown by the target of an invocation. 
FSharp.Core: One or more errors occurred. Microsoft.Azure.Documents.Client: 
The value 'left blank intentionally' specified  for 
query '$resolveFor' is invalid

I posted a while back on the documentdb github issues page, problems I was having with ReplaceDocumentAsync.

https://github.com/Azure/azure-documentdb-dotnet/issues/113

I wasn't too concerned about the fix because there was UpsertDocumentAsync. This issue seems to be related, or maybe their relation is just me! not being able to figure out what I'm doing wrong.

1
"Doesn't work" is not a good description of a problem. Please clarify what you mean by that. - Fyodor Soikin

1 Answers

1
votes

CreateDocumentUri needs consistent ids, either all ids or all _rids for the database, collection, and document