You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Discord注册API返回50035(Invalid Form Body)错误,如何修复?

Fixing Discord Register API Error 50035 ("Invalid Form Body")

Let's break down what's going wrong here and get your API call working properly.

1. You're Putting Request Body Data in Headers (And Using the Wrong Parameter)

The biggest issue is that you're passing registration fields like email, password, and username in the headers instead of the request body. Discord's /auth/register endpoint expects these values in a JSON-formatted body, not as HTTP headers.

When you used the data parameter with requests.post(), it encodes the data as application/x-www-form-urlencoded (form data), which doesn't match what Discord's API is expecting. That's exactly why you're getting the Invalid Form Body error (code 50035).

2. Missing Critical Headers & Incorrect Data Types

Discord's API also requires specific headers to accept your request, and some fields need the right data type (like consent should be a boolean, not a string).

Corrected Code

Here's the fixed version of your code with all these issues addressed:

import requests

# Assume these variables are properly defined elsewhere
email = "your_valid_email@example.com"
password = "your_strong_password"
username = "your_desired_username"

# Required headers for Discord API
headers = {
    "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/118.0.0.0 Safari/537.36",
    "Content-Type": "application/json"
}

# Registration payload (this goes in the request body, not headers)
payload = {
    "consent": True,  # Use boolean instead of string "true"
    "date_of_birth": "2000-08-05",
    "email": email,
    "password": password,
    "username": username
}

response = requests.post(
    "https://discord.com/api/v9/auth/register",
    headers=headers,
    json=payload  # Use json parameter to send JSON-formatted body
)

print(f"Status Code: {response.status_code}")
print(response.text)

Key Fixes Explained:

  • Moved registration data to payload: This is the correct place for user registration details, not HTTP headers.
  • Used json=payload instead of data: This tells requests to send the body as JSON and automatically sets the correct Content-Type (though we explicitly set it too for clarity).
  • Fixed consent type: Changed from string "true" to boolean True—Discord's API strictly validates data types for this field.
  • Added User-Agent header: Discord blocks requests without a valid user agent (it looks like a bot otherwise). Using a browser-like user agent helps avoid this.

If You Still Get Errors After This:

Discord's registration process has additional safeguards that might block your request:

  • Missing fingerprint: The API often requires a fingerprint field (a unique identifier generated by the Discord client). You can grab this from your browser's developer tools when registering manually.
  • CAPTCHA Verification: Discord now requires human verification for most new registrations. Automating this is tricky, as you'd need to integrate a CAPTCHA-solving service (which violates Discord's Terms of Service in most cases).

内容的提问来源于stack exchange,提问作者WagonToZiomal

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.04 18:45:48