0

I am using PHP with Guzzle to send a document via Telegram Bot API using sendDocument.
The file is hosted on Amazon S3 with a URL like:

https://telegramfile.xxx.amazonaws.com/file/preview/chat/02AAE430F214770D1534C6364813C1FC.txt

I try to send it like this:

$response = $client->post(
    "https://api.telegram.org/bot$botToken/sendDocument",
    [
        'json' => [
            'chat_id' => $chatId,
            'document' => $fileUrl
        ]
    ]
);

The request returns:

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

Things I have checked:

  • The S3 URL is public and accessible (tested with curl).
  • Content-Type is application/octet-stream.
  • The file is less than 50 MB.

Other URLs (like public GitHub raw files) work fine with the same code.

Question: Why does Telegram reject the S3 URL? How can I correctly send files from S3 using sendDocument?

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.