Screenshot API error ยท HTTP 422

Action failed

action_failed

A step of actions, or the scripts, could not do what it says. The message names the step by its index and type (actions.2 (click)) and why it failed, and the X-Actions-Completed header says how many steps completed, for example 2/5.

How to recognize it

The API answers with status 422 and a JSON body with the message and the error.code action_failed, for example:

HTTP/1.1 422
Content-Type: application/json

{
  "error": {
    "code": "action_failed",
    "message": "The step actions.2 (click) failed: its element was not found, shown or ready within its timeout_ms. Mark it optional to go on without it."
  },
  "message": "The step actions.2 (click) failed: its element was not found, shown or ready within its timeout_ms. Mark it optional to go on without it."
}

Common causes

  • The step’s element was not found, not visible or not ready within its timeout_ms (5 seconds by default): a changed selector, an element that appears later, or one behind a dialog.
  • A wait_for_selector step whose selector did not match in time, or a wait_for_navigation step for which no navigation came.
  • A select step whose element is no <select>, or none of whose options has one of its values.
  • An evaluate step or the scripts threw an error or did not finish in time (The scripts threw an error.).
  • A click_accept step that found no accept button of a cookie consent dialog.

How to fix it

  1. Mark a step that does not always apply as "optional": true: it is skipped instead of failing the render.
  2. Raise the step’s timeout_ms, or put a wait_for_selector step before it.
  3. Find the first step that fails: X-Actions-Completed counts the steps before it. Check its selector in the browser’s console on the same page.
  4. Run the code of an evaluate step or of scripts in the browser’s console on the same page.

Billing

The first 25 failure conditions a day are free for each account (action_failed, selector_not_found, content_condition_failed and request_failed together, per UTC day); after that, each counts as one request, like a render. Once an evaluate step or the scripts ran in the page, any failure that is not ours is billed 1, without the free allowance, because that code could read the page. A 500 is ours and never billed. The steps themselves cost nothing extra.

Related parameters

actions, scripts, scripts_wait_until. Each is described in the take endpoint reference.

Every response carries an X-Request-Id header. If this page does not explain the error, write to support@screenshotbase.com with that id. All statuses: status codes.

Other API errors

Screenshot API

Take screenshots from your code

screenshotbase renders any website in a real browser and returns the image: full page or viewport, any device size, retina, from 100+ countries, with cookie banners and ads hidden.

/v1/take documentation Screenshot API All documentation

300 free screenshots every month. No credit card required.

GET https://api.screenshotbase.com/v1/take?url=https://example.com&full_page=true

# Response: the image (PNG, JPG, WebP, AVIF or GIF)
curl -G "https://api.screenshotbase.com/v1/take" \
  --data-urlencode "url=https://example.com" \
  -d viewport_width=1280 -d viewport_height=800 \
  -d format=png \
  -H "apikey: YOUR-API-KEY" \
  -o screenshot.png

More free tools

Start using our Screenshot API for free today!

Get 300 requests / month for free