Skip to main content

error-handling Scenario 3 — Handle HTTP 429 with Retry-After

Written by RTILA X Engineering Team

Intermediate ~6 min
Prerequisites: error-handling/1 error-handling/2

What You'll Learn

Simulate offline conditions and retry

Real-World Use Case

Testing network resilience

LIVE DEMO

Status: 429 Too Many Requests
Retry-After: 5 seconds
EXPECTED OUTPUT

RTILA X PROJECT JSON

    {
  "name": "Handle_HTTP_429_Retry_After",
  "settings": {
    "urls": [
      "https://learn.rtila.com/scenarios/error-handling/3"
    ]
  },
  "datasets": {
    "api_data": {
      "item_selector": "css=table.rate-limit-data tbody tr",
      "properties": [
        {
          "name": "endpoint",
          "type": "text",
          "selector": "css=td:nth-child(1)"
        },
        {
          "name": "status",
          "type": "text",
          "selector": "css=td:nth-child(2)"
        },
        {
          "name": "latency",
          "type": "text",
          "selector": "css=td:nth-child(3)"
        }
      ]
    }
  },
  "commands": [
    {
      "command": "wait_for_selector",
      "params": {
        "selector": "css=.api-status"
      }
    },
    {
      "command": "if",
      "params": {
        "condition": {
          "type": "script",
          "expression": "document.querySelector('.api-status').textContent.includes('429')"
        },
        "then": [
          {
            "command": "wait",
            "params": {
              "timeout": 5000
            }
          },
          {
            "command": "goto",
            "params": {
              "url": "https://learn.rtila.com/scenarios/error-handling/3"
            }
          }
        ],
        "else": []
      }
    },
    {
      "command": "wait_for_selector",
      "params": {
        "selector": "css=.api-data"
      }
    },
    {
      "command": "extract_data",
      "params": {
        "dataset": "api_data"
      }
    }
  ]
}
  

RTILA X Concepts

HTTP 429 responses include a Retry-After hint. The automation detects the rate-limit status, waits for the suggested delay, and navigates again to access the successful API data.

Did you complete this scenario?

Ready to run this automation?

Copy the project JSON above, open RTILA X, create a new project, and paste it.

This scenario covers 2 RTILA X commands and is referenced in 1 learning article.

Continue Learning

Was this helpful?