# Error: Server Actions require the request body to be parsed as FormData or JSON. Received unexpected content type: multipart/form-data

- **ID:** `nextjs/server-action-formdata-multipart`
- **Domain:** nextjs
- **Category:** protocol_error
- **Verification:** ai_generated
- **Fix Rate:** 85%

## Root Cause

A Server Action is called with a multipart/form-data request (e.g., from a file upload form without proper encoding), but Server Actions only support application/x-www-form-urlencoded, text/plain, or application/json content types. multipart/form-data is not supported.

## Version Compatibility

| Version | Status | Introduced | Deprecated |
|---------|--------|------------|------------|
| Next.js 14.0.0 | active | — | — |
| Next.js 14.1.0 | active | — | — |
| Next.js 14.2.0 | active | — | — |

## Workarounds

1. **Remove the file input from the form and handle file uploads separately via an API route. Example: Use a standard form with action={serverAction} for text fields only, and add a separate file upload component that posts to /api/upload.** (90% success)
   ```
   Remove the file input from the form and handle file uploads separately via an API route. Example: Use a standard form with action={serverAction} for text fields only, and add a separate file upload component that posts to /api/upload.
   ```
2. **Convert the form data to JSON in a client-side handler before calling the Server Action. Example: `const formData = new FormData(event.target); const json = Object.fromEntries(formData.entries()); await serverAction(json);`** (85% success)
   ```
   Convert the form data to JSON in a client-side handler before calling the Server Action. Example: `const formData = new FormData(event.target); const json = Object.fromEntries(formData.entries()); await serverAction(json);`
   ```
3. **Use a third-party library like 'formidable' in an API route to handle multipart uploads, then call the Server Action from the API route with the parsed data as JSON.** (80% success)
   ```
   Use a third-party library like 'formidable' in an API route to handle multipart uploads, then call the Server Action from the API route with the parsed data as JSON.
   ```

## Dead Ends

- **** — Multipart/form-data is the default for forms with file inputs, but Server Actions reject it; the form must be sent as URL-encoded or plain text. (100% fail)
- **** — If the fetch still sends multipart/form-data (the default for FormData), the same error occurs. The fetch must explicitly set Content-Type to application/json. (90% fail)
- **** — HTML forms do not support JSON enctype; the browser will ignore it and use the default (application/x-www-form-urlencoded for non-file forms, multipart/form-data for file forms). (100% fail)
