TechBuzzPro

Discord Webhook Invalid Form Body Error Fix

· 4 min read · Discord

In this article
  1. What You'll Need
  2. Step-by-Step
  3. Common Mistakes
  4. Tips
  5. Troubleshooting
  6. Frequently Asked Questions

Getting a "Invalid Form Body" error when sending a Discord webhook usually means your JSON payload is malformed, too long, or contains fields with invalid types. The fix is to correct the JSON structure and ensure it meets Discord's limits. Below is a step-by-step guide to diagnose and resolve this error.

What You'll Need

  • The webhook URL (starts with https://discord.com/api/webhooks/...)
  • Access to the tool or script sending the webhook (e.g., a bot, cron job, or API tester like Postman)
  • Basic knowledge of JSON syntax

Step-by-Step

  1. Check the webhook URL. Make sure you copied the full URL, including the ID and token at the end. A truncated URL will cause a 404 or invalid request error.
  2. Validate your JSON payload. Use a JSON validator (like jsonlint.com) to ensure your payload is valid. Common mistakes: trailing commas, missing quotes around keys, or unescaped quotes inside strings.
  3. Check the content field. The content field must be a string (text). If you send a number or object, Discord will reject it. Also, the content must be 2000 characters or fewer.
  4. Verify embed structure. If you're sending embeds, each embed must be an object, not an array. The embeds field itself is an array of objects. Each embed has its own limits: title (256 chars), description (4096 chars), fields (25 max, each name 256 chars, value 1024 chars), footer text (2048 chars), etc.
  5. Ensure no extra fields. Discord only accepts specific top-level fields: content, username, avatar_url, tts, embeds, allowed_mentions, components, attachments, and flags. Any other field will cause an invalid form body error.
  6. Check allowed mentions. If you use allowed_mentions, ensure the structure is correct: {"parse": ["users", "roles"], "roles": ["role_id"], "users": ["user_id"]}. The parse array can only contain "users", "roles", and "everyone".
  7. Test with a simple payload. Send a minimal payload like {"content": "test"} to confirm the webhook works. If that works, add fields one by one to isolate the problem.
  8. Check your HTTP method. Use POST, not GET or PUT, to send webhooks. Also, set the Content-Type header to application/json if you're sending raw JSON.
  9. If using a library, update it. Some old Discord libraries may send outdated payloads. Update your library or script to the latest version.

Common Mistakes

  • Forgetting to escape quotes inside JSON strings, especially in content or embed descriptions.
  • Using single quotes instead of double quotes for JSON keys and strings.
  • Sending an empty content field with no embeds—Discord requires at least one of these.
  • Exceeding character limits on content, embed titles, or field values.
  • Incorrectly nesting arrays—e.g., putting embeds as an object instead of an array.
  • Including a trailing comma after the last item in an array or object.

Tips

  • Use a webhook testing tool like Discord's own webhook URL in a browser (you can paste the URL and add ?wait=true to see detailed errors).
  • Use a JSON formatter to visually inspect your payload for missing brackets or commas.
  • Keep a backup of a known-working payload to compare against when debugging.
  • If sending files, use multipart/form-data instead of JSON. The JSON payload must then only contain the content and embeds fields; attachments are sent as separate parts.
  • Use the wait=true query parameter on the webhook URL to receive a response with detailed error messages from Discord's API.

Troubleshooting

If the error persists after checking the above:

  1. Test the webhook URL directly by pasting it in a browser with ?wait=true and sending a simple POST via a tool like Postman or curl. This isolates whether the issue is in your code or the webhook itself.
  2. Check Discord's API status at status.discord.com to ensure there's no ongoing outage affecting webhooks.
  3. Regenerate the webhook URL in your Discord server settings (Server Settings > Integrations > Webhooks). Sometimes the URL can be corrupted or expired.
  4. If using a bot token instead of a webhook URL, ensure you're using the correct endpoint (/channels/{channel.id}/messages) and that the bot has permission to send messages in that channel.
  5. Check for non-ASCII characters that might be misinterpreted. Ensure your payload is UTF-8 encoded.

Frequently Asked Questions

Why does my webhook work in Discord's test but not in my script?

Discord's test sends a specific payload. Your script likely sends a malformed JSON or includes unsupported fields. Compare your payload to the one Discord sends.

Can I send more than 2000 characters in a webhook?

No, the content field is limited to 2000 characters. For longer messages, use embeds (up to 4096 characters in the description) or split the message into multiple webhook calls.

What does "Invalid Form Body" mean exactly?

It means Discord's API rejected your JSON payload because it didn't match the expected schema—either a field is missing, has the wrong type, or exceeds a limit.

Can I send a webhook without a content field?

Yes, but you must include at least one embed. An empty payload with no content and no embeds will be rejected.

How do I fix "embeds.0.description: This field is required"?

This error means your embed object is missing the description field. Add a description string to your embed, or remove the embed if it's not needed.

Does the order of fields matter in the JSON?

No, JSON objects are unordered. Discord parses fields by name, not position.