# HTTP 415 Unsupported Media Type

**Code:** `415` · **Category:** HTTP · **Seen on:** JavaScript, .NET

The server refuses the request because the body’s Content-Type isn’t one it accepts.

## Meaning

The endpoint expects a specific body format (usually `application/json`) and the request declared — or defaulted to — something else, like `text/plain` or `application/x-www-form-urlencoded`.

## Common causes

- Missing `Content-Type: application/json` header
- Sending form data to a JSON-only endpoint (or vice versa)
- Wrong charset or vendor media type (`application/vnd.api+json`)
- Uploading a file type the endpoint doesn’t allow

## Quick fix

1. Set the correct Content-Type header for the body you send
2. Check API docs for the required media type
3. With `FormData` in browsers, do NOT set Content-Type manually — the browser adds the boundary

## Detailed fix by platform

### JavaScript

1. JSON vs multipart:

```javascript
// JSON
fetch(url, { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify(data) });
// File upload — let the browser set multipart/form-data; boundary=...
const fd = new FormData(); fd.append('file', file);
fetch(url, { method: 'POST', body: fd });
```


### .NET

1. ASP.NET Core `[ApiController]` requires JSON by default; use `[FromForm]` for form posts.

## How to diagnose

1. **Header** — What Content-Type did the client send?
2. **Endpoint** — What does the endpoint consume?
3. **Body** — Does the body actually match the declared type?

---
Source: [WhatIsMyError](https://whatismyerror.com/errors/http/415-unsupported-media-type)
