简体   繁体   English

如何从Java中的Watson API响应中读取X-RateLimit HTTP标头

[英]How to read X-RateLimit HTTP header from Watson API response in Java

I'm working on a Java chatbot application using the Watson Conversation Service and I want to retrieve the information about my API limit. 我正在使用Watson Conversation Service开发Java聊天机器人应用程序,我想检索有关我的API限制的信息。

API Reference states: The response to each HTTP request includes headers you can use to determine whether you are close to the rate limit: X-RateLimit-Reset: the time the current timer expires (in UNIX epoch time) X-RateLimit-Remaining: the number of requests remaining in the current time window X-RateLimit-Limit: the total number of requests allowed within the time window https://www.ibm.com/watson/developercloud/conversation/api/v1/?java#rate-limiting API参考状态:对每个HTTP请求的响应均包括可用于确定您是否接近速率限制的标头:X-RateLimit-Reset:当前计时器到期的时间(以UNIX纪元时间)X-RateLimit-Remaining:当前时间窗口中剩余的请求数X-RateLimit-Limit:时间窗口内允许的请求总数https://www.ibm.com/watson/developercloud/conversation/api/v1/?java#rate -限制

I am interested in the values for Limit and Remaining in order to generate a warning if the remaining value is lower then a particular portion. 我对“限制”和“剩余”的值感兴趣,以便在剩余值低于特定部分时生成警告。 Browsing through the code of the Java-SDK ( https://github.com/watson-developer-cloud/java-sdk/ ) I couldn't find a way to retrieve this information from the message response. 浏览Java-SDK( https://github.com/watson-developer-cloud/java-sdk/ )的代码,我找不到从消息响应中检索此信息的方法。 Is it somehow possible? 有可能吗?

Erik, I think you are right that there is no proper way to get the rate limit information using the current Java SDK. Erik,我认为您是对的,没有使用当前Java SDK来获取速率限制信息的正确方法。 You should open an issue against the Java SDK with the information you have collected above requesting this feature. 您应该针对Java SDK提出一个问题,其中包含您在上面要求此功能时收集的信息。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 How to read Custom Http Header from the response using com.sun.jersey.api? - How to read Custom Http Header from the response using com.sun.jersey.api? 如何从 ZD52387880E1EA25317A72D3 中的 HTTP 响应中获取特定的 HTTP header 值 - How to get specific HTTP header values from an HTTP response in Java? HTTP响应标头-如何从HTTP响应标头Java中检索特定值 - HTTP Response header - how to retrieve particular value from the HTTP Response Header java Java中的HTTP / 2响应标头 - HTTP/2 Response Header in Java Java中的Http响应标头 - Http Response Header in java 如何在HTTP get请求的标头中设置X-Api-Key - How to set X-Api-Key in the header of HTTP get request 如何在 Java 过滤器中更改 HTTP 响应内容长度标头 - How to change the HTTP response content length header in Java Filter 如何从每个SOAP响应/请求添加/读取自定义标头抛出Java - How to Add/Read Custom Header from each SOAP Response/Request throw Java Java:如何从响应中删除标头? - Java: How to remove a header from a response? 使用 X-Checksum-Sha1 header 和 Apache 的 HTTP 客户端在 Java 上传到工件时出现 409 响应 - 409 response when uploading to artifactory using X-Checksum-Sha1 header with Apache's HTTP client in Java
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM