# request.malformed

The request cannot be read: invalid JSON, the wrong content type

Profile: [Errors](https://www.prongs.dev/docs/intents/errors.md) · Raised with: [`fail()`](https://www.prongs.dev/docs/profiles/errors.md) · Status: `400` · Message: yours

## Example

```ts
return fail('request.malformed', 'Invalid JSON.');
```

The caller gets

```bash
HTTP 400

{
  "ok": false,
  "error": "Invalid JSON.",
  "code": "request.malformed"
}
```

## Choosing between neighbours

Find the row that describes your case, and use the intent on the right.

| If it is for… | Use |
|---|---|
| The request cannot be read: invalid JSON, the wrong content type | `request.malformed` (this page) |
| A readable request with a wrong value | [`request.invalid`](https://www.prongs.dev/docs/intents/request/invalid.md) |

## Connections

Declared in the registry, both directions. Where an intent is used in your own code is something check and the gallery see; this site has no app code.

- Built from: [`status.badrequest`](https://www.prongs.dev/docs/intents/errors.md#status-badrequest)

## For registry authors

**Starter intents.** These are the intents `prongs add errors` puts in your registry, raised with [`fail()`](https://www.prongs.dev/docs/profiles/errors.md). Change the messages to suit your app, and the statuses through the [`status.*`](https://www.prongs.dev/docs/intents/errors.md#status) intents they are built from.

The entry `prongs add errors` writes into your registry. Change the message here, or the status through its [`status.*`](https://www.prongs.dev/docs/intents/errors.md#status) ref.

```ts
'request.malformed': {
  kind: 'semantic',
  description: 'The request cannot be read: invalid JSON, the wrong content type',
  refs: ['status.badrequest'],
  keywords: ['json', 'parse', 'malformed'],
  notFor: [
    {
      context: 'a readable request with a wrong value',
      instead: 'request.invalid',
    },
  ],
  binding: { publicMessage: 'Invalid request.' },
},
```
