1

I'm trying to send a PDF from a Telegram BOT.When I select a file from my server , it shows this message:

Client error: `POST https://api.telegram.org/botXXXX/sendDocument` resulted in a `400 Bad Request` response:\n {"ok":false,"error_code":400,"description":"Bad Request: wrong file identifier/HTTP URL specified"}\

But when I choose from other servers, it works fine!

my file is this directory :

http://109.169.XX.XX:7070/pdfs/sample.pdf

Should the server port be 80?

code :

$data=[
        'chat_id' =>'YYYYY' ,
        'caption' =>'test' ,
        'document'=>"http://109.169.xx.xx:7070/pdfs/sample.pdf",
        ];


$url = 'https://api.telegram.org/bot' . $token . '/sendDocument';

$client= new \GuzzleHttp\Client([]);
$result  = client->post( $url,['form_params'=>$data]);
4
  • Share your code. Commented Apr 21, 2018 at 20:33
  • @Evert code added Commented Apr 21, 2018 at 20:54
  • What mime type does the .pdf return when opening it? (Content-Type header) Commented Apr 21, 2018 at 21:39
  • @Evert MIME Type: application/pdf Commented Apr 22, 2018 at 6:49

1 Answer 1

2

My problem has been resolved

I had to transfer my code from Port 7070 to port 80

For example, my PDF file address is :

http://109.169.XX.XX/pdfs/sample.pdf

I suggest if you encounter this problem, Be sure your code to run on port 80, and as far as possible use the domain instead of IP

Sign up to request clarification or add additional context in comments.

Comments

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.