4xx Client ErrorRFC 9110
411Length Required
Content-Length header is required.
What it means
The server refuses to accept the request without a defined Content-Length header. The client must send the Content-Length header with the size of the request body.
When to use it
- ✓Server requires Content-Length for POST/PUT requests
Code Examples
Fix: add Content-Length header
javascript
// axios handles this automatically
// fetch example:
const body = JSON.stringify(data);
fetch('/api', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'Content-Length': Buffer.byteLength(body).toString(),
},
body,
});