Discord API Error: Invalid Form Body

I have setted the image for the embed message, and when I use command, it doesn’t send the message and errors:


9:36 PM

embed.image.url: Not a well formed URL.

9:36 PM

at item.request.gen.end (/rbd/pnpm-volume/bb4a590d-fd8f-4c98-b899-7f1655d4cceb/node_modules/.registry.npmjs.org/discord.js/11.5.1/node_modules/discord.js/src/client/rest/RequestHandlers/Sequential.js:85:15)

9:36 PM

at then (/rbd/pnpm-volume/bb4a590d-fd8f-4c98-b899-7f1655d4cceb/node_modules/.registry.npmjs.org/snekfetch/3.6.4/node_modules/snekfetch/src/index.js:215:21)

9:36 PM

at <anonymous>

9:36 PM

at process._tickCallback (internal/process/next_tick.js:189:7)

9:36 PM

(node:20524) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 4)```

How can I fix this?

What image URL are you sending?

Here my code:

if (!biography) Profile.setImage ('https://dummyimage.com/2000x500/2f2f2f/ffffff&text=This user has not a bio.')
if (biography) Profile.setImage (`https://dummyimage.com/2000x500/2f2f2f/ffffff&text=${biography}`)

If you want to use an image in the embed it has to end with, png.,.jpg.,ect.

1 Like

It would be ffffff.png&text=
instead of ffffff&text=

It erros again, so this haven’t worked.

Eray, selam.
Invalid Form Body gönderilecek mesajla alakalı bir hatadır.
Embedlardan birinde oluşuyor muhtemelen.
CodAre’dan selam :slight_smile:

CodAre’dan Aleyküm Selam. :slight_smile:
Peki nasıl çöczebilirim? Yukarıya bakar mısın?

Muhtemelen ${biography} olarak tanımladığın şey tanımsızdır diye düşünüyorum.
Yukarıdaki arkadaşların yazdığı gibi sonuna .png eklersen de çözme ihtimalin var :slight_smile:
Aldığın hata: embed.image.url: Not a well formed URL.
İyi düzenlenmemiş bir URL anlamına geliyor.
Yani sonuna .png .jpg şeklinde bir uzantı eklemen lazım diye tahmin ediyorum.


Denedim, fakat, yine hata veriyor.

I believe your problem is that Discord.js first validates the URL. So if the URL has spaces in it it throws the Invalid Form Body error.

You probably need to encode the ${biography} part. You can do this using encodeURIComponent

Here’s a fix for your code:

if (!biography) Profile.setImage ('https://dummyimage.com/2000x500/2f2f2f/ffffff&text=This%20user%20has%20not%20a%20bio.')
if (biography) Profile.setImage (`https://dummyimage.com/2000x500/2f2f2f/ffffff&text=${encodeURIComponent(biography)}`)
1 Like

It has worked, thank you very much! :heart:

1 Like