1
votes

Trying to delete a doc based on the Id in cosmosdb from Java(SpringBoot) Azure function using DocumentClient

The key and uri used are absolutely correct

DocumentClient client = new DocumentClient(cosmosDBUri, cosmosDBKey, null, null);
         try {
                String documentLink = String.format("/dbs/%s/colls/%s/docs/%s", "db1", "col1", "newId");
                context.getLogger().info("documentLink: " + documentLink);
                client.deleteCollection(documentLink, null);
            } catch (Exception e) {

The input authorization token can't serve the request. Please check that the expected payload is built as per the protocol, and check the key being used. Server used the following payload to sign: 'delete docs dbs/db1/colls/col1/docs/newId thu, 29 aug 2019 13:40:44 gmt

' ActivityId: *********************, Microsoft.Azure.Documents.Common/2.5.1, StatusCode: Unauthorized

1

1 Answers

0
votes

You are calling deleteCollection when you should be using deleteDocument.

In addition, double check that you are not using a read-only key.