You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何获取JIRA REST API /rest/api/3/field的速率限制值及解决429错误

解决JIRA REST API 429请求超限问题

获取API限制值

JIRA的REST API会通过响应头返回限流相关核心参数,你直接从请求(包括触发429的请求)的响应头里读取即可:

  • X-RateLimit-Limit:单位时间内允许的最大请求次数
  • X-RateLimit-Remaining:当前周期内剩余的可用请求次数

用Axios的话,可从错误对象中提取这些值,示例代码:

const limit = error.response.headers['x-ratelimit-limit'];
const remaining = error.response.headers['x-ratelimit-remaining'];

确定下一次调用时间

触发429后,可通过两种方式判断可重试时间:

  1. 优先读取Retry-After响应头:该字段直接给出需要等待的秒数,拿到后等待对应时长再发起请求即可。Axios中读取方式:
    const retryAfter = error.response.headers['retry-after'];
    // 等待retryAfter秒后重试
    
  2. 用X-RateLimit-Reset计算:如果响应头无Retry-After,可读取X-RateLimit-Reset(Unix时间戳,单位秒),用该时间戳减去当前时间,得到需等待的秒数:
    const resetTime = error.response.headers['x-ratelimit-reset'];
    const waitSeconds = resetTime - Math.floor(Date.now() / 1000);
    

内容的提问来源于stack exchange,提问作者Mohan Krishna

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.08 01:12:04