微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

如何在 COMOS v4 同步 api container.queryItems() 中获取 eTag 值

如何解决如何在 COMOS v4 同步 api container.queryItems() 中获取 eTag 值

在使用 comsos v4 java async apis 时遇到这个问题。 我看到 eTag 值,如果使用了 container.readItem(),但不是在 container.queryItems() 中。 当我检查 queryItem 响应中的响应标头数据时,eTag 为空。 谁能告诉我,这是 cosmos API 错误还是我遗漏了什么?

        responseDocuments
                .byPage(1)
                .log()
                .flatMap(person-> {
                    person.getResults().stream().forEach(document-> {
                        if(document.get("optInStatus") != null) {
                        } else {
                            list.add(gson.fromJson(gson.toJson(document,LinkedHashMap.class),Person.class));
                        }

                    });
                    System.out.println(person.getResponseHeaders().get("etag")); // coming as null
                    System.out.println(person.getContinuationToken());
                    System.out.println(person.getResponseHeaders().toString());
                    return Flux.empty();
                })
                .blockLast();

解决方法

如果是 cosmos API 错误还是我遗漏了什么?

您没有遗漏任何内容,我认为这不是错误。我尝试了 REST API。它也不会在响应标头中提供 _eTag 属性。如果您在查询项目时需要该系统属性,您可以将该属性添加到您的 POJO。

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。