node-telegram-bot-api icon indicating copy to clipboard operation
node-telegram-bot-api copied to clipboard

400 Bad Request: wrong file identifier/HTTP URL specified

Open meness opened this issue 8 years ago • 27 comments

I am using the latest version of the library.

Expected Behavior

This has to handle http://dl.nex1music.ir/1396/07/03/Mohsen%20Salehi%20-%20Bigharari.mp3 URL, but gives an error. The given URL works out of the library properly.

Actual Behavior

2017-09-25T17:35:53.528481+00:00 app[web.1]: Unhandled rejection Error: ETELEGRAM: 400 Bad Request: wrong file identifier/HTTP URL specified 2017-09-25T17:35:53.528493+00:00 app[web.1]: at BaseError (/app/node_modules/node-telegram-bot-api/src/errors.js:10:5) 2017-09-25T17:35:53.528495+00:00 app[web.1]: at TelegramError (/app/node_modules/node-telegram-bot-api/src/errors.js:56:5) 2017-09-25T17:35:53.528496+00:00 app[web.1]: at request.then.err (/app/node_modules/node-telegram-bot-api/src/telegram.js:213:15) 2017-09-25T17:35:53.528496+00:00 app[web.1]: at tryCatcher (/app/node_modules/bluebird/js/release/util.js:16:23) 2017-09-25T17:35:53.528497+00:00 app[web.1]: at Promise._settlePromiseFromHandler (/app/node_modules/bluebird/js/release/promise.js:512:31) 2017-09-25T17:35:53.528497+00:00 app[web.1]: at Promise._settlePromise (/app/node_modules/bluebird/js/release/promise.js:569:18) 2017-09-25T17:35:53.528498+00:00 app[web.1]: at Promise._settlePromise0 (/app/node_modules/bluebird/js/release/promise.js:614:10) 2017-09-25T17:35:53.528498+00:00 app[web.1]: at Promise._settlePromises (/app/node_modules/bluebird/js/release/promise.js:693:18) 2017-09-25T17:35:53.528499+00:00 app[web.1]: at Async._drainQueue (/app/node_modules/bluebird/js/release/async.js:133:16) 2017-09-25T17:35:53.528500+00:00 app[web.1]: at Async._drainQueues (/app/node_modules/bluebird/js/release/async.js:143:10) 2017-09-25T17:35:53.528500+00:00 app[web.1]: at Immediate.Async.drainQueues (/app/node_modules/bluebird/js/release/async.js:17:14) 2017-09-25T17:35:53.528501+00:00 app[web.1]: at runCallback (timers.js:672:20) 2017-09-25T17:35:53.528501+00:00 app[web.1]: at tryOnImmediate (timers.js:645:5) 2017-09-25T17:35:53.528502+00:00 app[web.1]: at processImmediate [as _immediateCallback] (timers.js:617:5)

Steps to reproduce the Behavior

bot.onText(/^\/320$/, (msg, match) => {
    bot.sendChatAction(msg.chat.id,'upload_audio');
    bot.sendAudio(msg.chat.id, 'http://dl.nex1music.ir/1396/07/03/Mohsen%20Salehi%20-%20Bigharari.mp3');
});

meness avatar Sep 25 '17 17:09 meness

Same here.

kopiro avatar Jan 19 '18 22:01 kopiro

Same here too, with sendPhoto, and the photo URL works fine. Small jpeg image with 27KB. And it's the same image URL that I'm using in Facebook Messenger Bot that works. :(

https://wtmqerubko.localtunnel.me//img/promocao/20180212-20180217/10.jpg

hsandrade avatar Feb 22 '18 17:02 hsandrade

with sendPhoto, and the URL works fine, and the photo starts with a letter. https://trello-attachments.s3.amazonaws.com/5666779e6c24bb815183689c/597f79754996f872478fb5c8/600x264/79a80ac19fe1a4390cba895c920944f2/S61028-20071611.jpg

Ir1d avatar Apr 04 '18 03:04 Ir1d

Same here! 50 similar photos works fine. I have problem only with this one

https://s8.hostingkartinok.com/uploads/images/2018/08/d895b2471743055da86415f4af06b010.jpg

AleksandrBrukvin avatar Aug 09 '18 17:08 AleksandrBrukvin

same here with sendPhoto and sendDocument 3 out of 86 got problem

s7en75 avatar Jan 20 '19 06:01 s7en75

Same here. Any solution?

alihesari avatar May 19 '19 01:05 alihesari

+1 for sending audio

kirkins avatar Jul 24 '19 23:07 kirkins

I was able to fix it in my case.

I was generating the file name dynamically and it had a hidden newline at the end.

I ran .replace(/\n$/, "") on the value before passing it to send audio and it worked.

kirkins avatar Jul 25 '19 00:07 kirkins

I have the same issue with sendPhoto. Still not solution?

melroy89 avatar Aug 18 '19 22:08 melroy89

+1 still no solution ?

alytvynov avatar May 06 '20 14:05 alytvynov

@alytvynov Post the url here. It works in a lot of cases.

kamikazechaser avatar May 12 '20 15:05 kamikazechaser

still having the same issue

fmleo avatar May 22 '20 19:05 fmleo

I had solved this problem. And I answred here: https://stackoverflow.com/a/62672868/12866353

Hope this will help.

ESWZY avatar Jul 01 '20 08:07 ESWZY

Having the same issue with sendPhoto

WanjikuMac avatar Aug 05 '20 16:08 WanjikuMac

Having the same issue with sendPhoto

would you mind providing the image URL?

ESWZY avatar Aug 05 '20 16:08 ESWZY

Having the same issue with sendPhoto

would you mind providing the image URL?

https://telegram.ke.precisionag.org/photo/images/explore.jpg

It looks like your image is too big to send.

image

API doc says:

Provide Telegram with an HTTP URL for the file to be sent. Telegram will download and send the file. 5 MB max size for photos and 20 MB max for other types of content.

ESWZY avatar Aug 05 '20 17:08 ESWZY

Having the same issue with sendPhoto

would you mind providing the image URL?

https://telegram.ke.precisionag.org/photo/images/explore.jpg

It looks like your image is too big to send.

API doc says:

Provide Telegram with an HTTP URL for the file to be sent. Telegram will download and send the file. 5 MB max size for photos and 20 MB max for other types of content.

You're right, I changed the file size and it the sendPhoto method worked, thanks

WanjikuMac avatar Aug 05 '20 17:08 WanjikuMac

Same (i think) here, but with sendMessage method. I fixed when changed the URL from "http://host:port/etc..." to "http://host.some.thing:port/etc...".

Ps: host is hosted on a server only visible inside intranet.

pedrociarlini avatar Feb 03 '21 20:02 pedrociarlini

Prueben enviar la url pero acortada yo asi lo soucione

NixonEli avatar May 02 '21 23:05 NixonEli

Have the problem with sendAudio with URL string. So what is the solution ?

EDIT : I added ?random=64 and it worked.

ordimans avatar Sep 09 '21 09:09 ordimans

Have the problem with sendAudio with URL string. So what is the solution ?

EDIT : I added ?random=64 and it worked.

What a uncertainty of program! lol

ESWZY avatar Sep 11 '21 13:09 ESWZY

I've found out adding at the end of URL the query string: ?0 is enough to make it work 🤔

posti85 avatar Jul 06 '22 20:07 posti85

I've found out adding at the end of URL the query string: ?0 is enough to make it work 🤔

In my case I had a big difference, which I discovered after trying what you suggested.

this link does not generate error: https://ipfs.io/ipfs/QmUDTs1yCKM3XFHTEPABJb9b23VN77mbmoszRgbsQFQyYM/947.png this link does generate error: ipfs://QmT6kas8VTpkMZtT6EU2FJBejwnJTzVsMvxixSAMNWKitE/5293.png

placing '?0' at the end of the second link, it works 🤣

PerfectInsect avatar Jul 09 '22 04:07 PerfectInsect

@PerfectInsect I got the same problem, in my url https://lgd-1304243501.cos.ap-nanjing.myqcloud.com/huahuadan_1.mp4, placing ?0 it does not work, but pacing ?00 it works, amazing!🤣

Lgdck avatar Mar 03 '23 12:03 Lgdck

@PerfectInsect I got the same problem, in my url https://lgd-1304243501.cos.ap-nanjing.myqcloud.com/huahuadan_1.mp4, placing ?0 it does not work, but pacing ?00 it works, amazing!🤣

how did you do? i'm using your link and it didn't work, can you help me?

"""Unhandled rejection Error: ETELEGRAM: 400 Bad Request: wrong file identifier/HTTP URL specified""" image

Aekyios avatar Mar 11 '23 23:03 Aekyios

is this solved cause i also getting same error

ArvindKrPrajapati avatar Apr 28 '23 14:04 ArvindKrPrajapati

Just to add an info: it is in fact a problem of the telegram API, not the node-telegram-bot-api. I tried bypassing the SDK and making the request directly with a HTTP request and it failed with the same images I tried before.

But I noticed 2 different errors from 2 different images:

data: {
      ok: false,
      error_code: 400,
      description: 'Bad Request: MEDIA_EMPTY'
    }
 data: {
      ok: false,
      error_code: 400,
      description: 'Bad Request: failed to get HTTP URL content'
    }

I solved this problem when using the sendPhoto method using a buffer and passing this buffer as a parameter. But it doesn't work with "editMessageMedia" since it only accepts a string for the media.

const imgBuffer = await axios
			.get(movieImagePath, { responseType: "arraybuffer" })
			.then((response) => Buffer.from(response.data, "binary"))

lemoscaio avatar May 14 '23 18:05 lemoscaio

I've found out adding at the end of URL the query string: ?0 is enough to make it work 🤔

Worked! OMG! image

boyanich avatar Feb 10 '24 13:02 boyanich