Error when sending document (sendDocument)
See original GitHub issueHello, I’m currently facing an issue when I want to send a document. I tried 3 technics sending a local file, and a hosted file, neither document is sent.
Link to the Telegraf documentation
Sending local file (relativePath - asbolutePath)
bot.on('text', (ctx) => {
const localFile = '../../public/assets/test.txt'
return bot.telegram.sendDocument(process.env.CHAT_ID, request(localFile), [{disable_notification: true}]);
})
Sending hosted local file
With a simple server made by expressjs.
bot.on('text', (ctx) => {
const localFile = 'http://localhost:3000/assets/test.txt'
return bot.telegram.sendDocument(process.env.CHAT_ID, request(localFile), [{disable_notification: true}]);
})
Sending random remote file
bot.on('text', (ctx) => {
const remoteFile = 'http://www.lehtml.com/download/js_doc.pdf'
return bot.telegram.sendDocument(process.env.CHAT_ID, request(remoteFile), [{disable_notification: true}]);
})
I’m still getting this error
[nodemon] starting `node server.js`
App running on port 3000!
Error: 400: Bad Request: wrong URL host
at buildConfig.then.then.then.then (/path/to/project/node_modules/telegraf/core/network/client.js:232:17)
at <anonymous>
at process._tickCallback (internal/process/next_tick.js:188:7)
Failed to process updates. { Error: 400: Bad Request: wrong URL host
at buildConfig.then.then.then.then (/path/to/project/node_modules/telegraf/core/network/client.js:232:17)
at <anonymous>
at process._tickCallback (internal/process/next_tick.js:188:7)
code: 400,
response:
{ ok: false,
error_code: 400,
description: 'Bad Request: wrong URL host' },
description: 'Bad Request: wrong URL host',
parameters: {},
on:
{ method: 'sendDocument',
payload: { '0': [Object], chat_id: '-112511335', document: [Object] } } }
Does anyone has an idea of what I’m doing wrong ?
Issue Analytics
- State:
- Created 6 years ago
- Comments:5 (3 by maintainers)
Top Results From Across the Web
Common sending issues - DocuSign Support
Read this article if you are racing common sending issues like uploading/sending documents, errors like, "Page Cannot Be Displayed," email ...
Read more >Error when using document data for IPP send Document ...
Hello @hungnq39 the print payload is binary data of the remaining HTTP payload that immediately follows the document attributes. Please see ...
Read more >400 error when I send Document url toTelegram bot with api
my api code is: $url = 'https://api.telegram.org/bot'.$bot_id.'/sendDocument?chat_id='.$chat_id.' ...
Read more >Error: "Failed to send document(s) for E-Signature." Is ...
Primavera Unifier Cloud Service - Version N/A to N/A [Release NA]: Error: "Failed to send document(s) for E-Signature.
Read more >Unable to Send Document - Operation Failed!
Hi Mackie,. Thank you for reaching out and sorry about the trouble. As you receive error on the mobile application, did you check...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Okay I finally managed to use it 😃 In fact I did not needed to use
request
at all. You were right ! So the final code is :If the text sent is
doc
, then send the document. Thank you @sergeysova for your help !Please, show terminal output of