Unsupported Media Type (unsupported_media_type)
Quick Fix & Resolution
Set Content-Type: application/x-www-form-urlencoded (with body tx=<url_encoded_xdr>) or application/json.
Response Payload & SDK Handling
json
{
"type": "https://orion.stellarchain.io/horizon-errors/unsupported_media_type",
"title": "Unsupported Media Type",
"status": 415,
"detail": "The request has an unsupported content type. Presently, the only supported content type is application/x-www-form-urlencoded."
}typescript
import { Horizon } from '@stellar/stellar-sdk';
const server = new Horizon.Server('https://pubnet.stellarchain.io');
try {
const res = await server.ledgers().limit(10).call();
} catch (err: any) {
const problem = err?.response?.data;
if (problem?.type === 'https://orion.stellarchain.io/horizon-errors/unsupported_media_type') {
console.error('[unsupported_media_type] HTTP 415:', problem.detail, problem.extras);
}
}go
client := &horizonclient.Client{
HorizonURL: "https://pubnet.stellarchain.io",
}
_, err := client.Root()
if hErr := horizonclient.GetError(err); hErr != nil {
if hErr.Problem.Status == 415 {
log.Printf("Problem (%s): %s - extras=%v", hErr.Problem.Type, hErr.Problem.Detail, hErr.Problem.Extras)
}
}bash
curl -i -s "https://pubnet.stellarchain.io/" \
-H "Accept: application/hal+json"Common Root Causes
- Submitting
POST /transactionswithoutContent-Type: application/x-www-form-urlencodedorapplication/json.