Maaz Zindani

Loading the index…

↑↓ move↵ openesc close4072 pages
Node.js, PHP and APIs

DiscordAPIError[50035]: Invalid Form Body when sending a message or embed

ErrorDiscordAPIError[50035]: Invalid Form Body

Short answer

Error 50035 means the request body or its Content-Type is invalid. For messages the usual reasons are text over 2000 characters, an empty message with nothing to send, or an embed that breaks a size limit. Print the whole error object to see which field failed.

  • Applies to Discord API v10, Node.js 22
  • Updated
  • By Maaz Zindani, Senior Software Engineer

Fix it fast

  1. 1Find out which cause you have

    Print the full error, not only its message. Look for the field name in it: content points to the first cause below, embeds to the third.

    try {
      await channel.send(payload);
    } catch (err) {
      console.error(err);
    }
  2. 2Match what you see, then jump to its fix

    1. 1The failing field in the error is contentThe message text is longer than 2000 charactersFix
    2. 2The error appears when a variable is empty or undefined, for instance a reply built from an empty API resultThe message has nothing to sendFix
    3. 3The failing field path starts with embedsAn embed breaks a size limitFix

What does the error look like?

  • DiscordAPIError[50035]: Invalid Form Body

Cause 1 of 3

The message text is longer than 2000 characters

1Check

Discord accepts up to 2000 characters in the content field of a message.

console.log(payload.content?.length);

2Fix

Split the text into chunks of at most 2000 characters, or send long output as a file attachment.

for (let i = 0; i < text.length; i += 2000) {
  await channel.send(text.slice(i, i + 2000));
}

3Verify

Every chunk is accepted.

console.log(Math.max(...chunks.map(c => c.length)));

Confirmed by docs.discord.com

Did this fix it?

Cause 2 of 3

The message has nothing to send

1Check

At least one of content, embeds, sticker_ids, components, files, poll or shared_client_theme is required. An empty string with no embed or file therefore fails.

console.log(JSON.stringify(payload));

2Fix

Guard the send call so an empty payload is skipped or replaced with a fallback text.

if (!payload.content && !payload.embeds?.length && !payload.files?.length) {
  payload = { content: 'No results.' };
}

3Verify

The send succeeds with an empty source.

await channel.send(payload);

Confirmed by docs.discord.com

Did this fix it?

Cause 3 of 3

An embed breaks a size limit

1Check

Per embed: title 256 characters, description 4096, up to 25 fields, field name 256, field value 1024, footer text 2048, author name 256. All embeds in one message share a 6000-character total, and a message holds up to 10 embeds.

const e = payload.embeds?.[0];
console.log(e?.title?.length, e?.description?.length, e?.fields?.length);

2Fix

Trim each field to its limit, and move extra content into a second message.

const cut = (s, n) => (s.length > n ? s.slice(0, n - 1) + '…' : s);
embed.title = cut(embed.title, 256);
embed.description = cut(embed.description, 4096);

3Verify

Resend the embed.

await channel.send({ embeds: [embed] });

Confirmed by docs.discord.com

Did this fix it?

How do I stop it coming back?

  • Validate lengths before every send; the limits are fixed and documented.
  • Log the raw error body in your error handler so the failing field is never hidden.
  • Send long output as an attachment rather than as message text.

Sources

How was this page made?

I drafted this page with AI assistance from the official documents listed under Sources. Every cause above names the document that confirms it. I have not reproduced this fix on a machine of my own yet, so read it as documented guidance, not a test report. Found a mistake? Tell me.

Which stack is behind this page?

Projects of mine built on the same technologies:

Related fixes

Back end

ng serve says it cannot determine the project or target

Cannot determine project for command.

The Angular CLI looked through angular.json for a project that defines the target you asked for (serve, build, test) and found none, or found several and could not pick one.

3 causes, each with a fix

Back end

ng serve cannot find the dev-server builder package

Could not find the implementation for builder @angular/build:dev-server

The builder named in angular.json (for example @angular-devkit/build-angular:dev-server) is looked up as an npm package starting from the workspace root.

3 causes, each with a fix

Next step

Want this handled for good?

I look after servers, apps and releases end to end. Tell me what keeps breaking.