Screenshot API error ยท HTTP 422
Content condition failed
content_condition_failed
fail_if_content_contains, or lacked one of fail_if_content_missing, so the render failed as you asked. The message says which of the two.How to recognize it
The API answers with status 422 and a JSON body with the message and the error.code content_condition_failed, for example:
HTTP/1.1 422
Content-Type: application/json
{
"error": {
"code": "content_condition_failed",
"message": "The page contains a text of fail_if_content_contains."
},
"message": "The page contains a text of fail_if_content_contains."
}Common causes
fail_if_content_contains: the page shows one of the texts, such asAccess deniedorOut of stock.fail_if_content_missing(The page does not contain a text of fail_if_content_missing.): an expected text is not on the page, for example because it showed a login, a consent wall or an error instead.- Content that appears only after the render captured the page.
How to fix it
- Send the same request without the condition and with
format=pngto see what the page showed. - Wait for the content with
wait_for_selectororwait_untilbefore the conditions are checked. - Only the text the page shows counts. Case and white space do not matter, every other character does.
Billing
The first 25 failure conditions a day are free for each account (selector_not_found, content_condition_failed, request_failed and action_failed together, per UTC day). After that, each counts as one request, like a render. One exception: when an evaluate step of actions or the scripts ran in the page before the render failed, it is billed as one request, because that code could read the page, unless the failure is ours.
Related parameters
fail_if_content_contains, fail_if_content_missing, wait_for_selector. 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