无法使用Java中的DocumentClient从波斯菊删除文档

时间:2019-08-29 13:49:53

标签: spring-boot azure-functions azure-cosmosdb

尝试使用DocumentClient从Java(SpringBoot)Azure函数中删除基于cosmosdb中的ID的文档

使用的密钥和uri绝对正确

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) {
  

输入的授权令牌无法满足请求。请检查   根据协议构建了预期的有效负载,并检查   正在使用的密钥。服务器使用以下有效负载进行签名:'删除   docs dbs / db1 / colls / col1 / docs / newId周四,2019年8月29日13:40:44 gmt

     

'ActivityId:*********************,   Microsoft.Azure.Documents.Common / 2.5.1,状态代码:未经授权

1 个答案:

答案 0 :(得分:0)

当您应该使用deleteDocument时,您正在呼叫deleteCollection

此外,再次检查您是否没有使用只读密钥。