Telegram Bot API · error code

Telegram error 400: Bad Request: wrong type of the web page content

Permanent - do not retryHTTP 400400 Bad Request: files and media

Last verified against Telegram Bot API reference

What Telegram returns
Bad Request: wrong type of the web page content

What error 400 means

You sent media by HTTP URL and Telegram fetched the URL, but what came back was not the kind of file the method expects. The server-side error is WEBPAGE_MEDIA_EMPTY, which the Bot API server rewrites into this sentence. The download itself worked; a failed download would give failed to get HTTP URL content instead.

The Sending Files section of the reference explains the rule: when sending by URL the target file must have the correct MIME type (for example audio/mpeg for sendAudio), and in sendDocument sending by URL will currently only work for PDF and ZIP files. An HTML page, a redirect to a login screen, a JSON error from your CDN, or an image served as application/octet-stream all fail this check.

Signed URLs that expire, hotlink protection and image-resizing endpoints that return a placeholder page are frequent culprits, because the URL works in your browser but returns something else to Telegram's fetcher.

What it looks like

{"ok":false,"error_code":400,"description":"Bad Request: wrong type of the web page content"}

Why it happens

  • The URL returns an HTML page (login, consent, error or preview) instead of the file.
  • The server sends a generic or wrong Content-Type for the file.
  • sendDocument was given a URL for a type other than PDF or ZIP.
  • A signed or expiring URL had expired by the time Telegram fetched it.

How to fix Telegram error 400

  1. 1Fetch the URL with a plain HTTP client (no cookies) and check the status, Content-Type and first bytes.
  2. 2Serve the file with the correct MIME type, for example image/jpeg for sendPhoto.
  3. 3Use a stable public URL rather than one that needs cookies or headers.
  4. 4If you cannot control the host, download the file yourself and upload it as multipart/form-data.

How to stop it recurring

For anything other than simple public images, upload files directly or reuse a file_id from an earlier send; Telegram's FAQ notes file IDs can be reused. Size rules for URL sends versus uploads are on the files and media limits page.

Official reference: Telegram Bot API reference. See all Telegram error codes or the Telegram limits and quotas.

Related codes

Error 400 - quick answers

What does Telegram error 400 mean?

You sent media by HTTP URL and Telegram fetched the URL, but what came back was not the kind of file the method expects. The server-side error is WEBPAGE_MEDIA_EMPTY , which the Bot API server rewrites into this sentence. The download itself worked; a failed download would give failed to get HTTP URL content instead.

How do I fix Telegram error 400?

1. Fetch the URL with a plain HTTP client (no cookies) and check the status, Content-Type and first bytes. 2. Serve the file with the correct MIME type, for example image/jpeg for sendPhoto. 3. Use a stable public URL rather than one that needs cookies or headers. 4. If you cannot control the host, download the file yourself and upload it as multipart/form-data.

Should I retry after error 400?

No. Retrying the same request produces the same error; the condition has to be fixed first. Treat it as a permanent failure for that message and surface it, rather than looping.

Stop debugging Telegram by hand

Connect the channel through Conferbot: tokens, webhooks and retries are handled, failures show as readable status.