Reputation: 541
I am trying to delete a document from CosmosDB using the code below but each time Keep getting the following error: "Microsoft.Azure.Documents.DocumentClientException: Entity with the specified id does not exist in the system"
The document is definitely in the database:
This is the code I'm using:
this.client = new DocumentClient(new Uri(EndpointUri), PrimaryKey);
var docUri = UriFactory.CreateDocumentUri(DatabaseName, CollectionName, documentId);
var result = await this.client.DeleteDocumentAsync(docUri, new RequestOptions { PartitionKey = new PartitionKey("/id") });
Anyone any idea on what the issue may be?
Thanks
Upvotes: 2
Views: 2108
Reputation: 7200
The PartitionKey
property in the RequestOptions
class represents the value not the definition of the partition key.
This means that yous delete line should be this:
var result = await this.client.DeleteDocumentAsync(docUri, new RequestOptions { PartitionKey = new PartitionKey(documentId) });
Upvotes: 5