Screenshot API error ยท HTTP 502
Request of the page failed
request_failed
fail_if_request_failed failed, with a network error (named in the message, such as ERR_CONNECTION_FAILED) or an HTTP status of 400 or more. The render failed as you asked.How to recognize it
The API answers with status 502 and a JSON body with the message and the error.code request_failed, for example:
HTTP/1.1 502
Content-Type: application/json
{
"error": {
"code": "request_failed",
"message": "A request of the page that matches fail_if_request_failed failed (HTTP error status)."
},
"message": "A request of the page that matches fail_if_request_failed failed (HTTP error status)."
}Common causes
- A script, stylesheet, image or API call of the page that answered 404 or 500, or did not load at all.
- A pattern that matches more than meant: a pattern matches the whole URL, and
*stands for any characters.
How to fix it
- Open the page with the browser’s developer tools (Network tab) and look for the failed request.
- Narrow the pattern, for example
https://cdn.example.com/*or*.cssinstead of*. - With
diagnostics=truethe error body adds the render’s diagnostics, with a link to a HAR file of the page’s requests.
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_request_failed, diagnostics. 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