docs: clarify 415 vs 400 errors for request.json
Description
Clarifies the distinction between 415 and 400 error codes when using request.json, aligning the JavaScript patterns documentation with the API reference.
Changes
- Updated "Receiving JSON in Views" section to specify:
- 400 Bad Request: for invalid JSON body
- 415 Unsupported Media Type: for missing/incorrect Content-Type header
- Updated "Making a Request with fetch" section for consistency
Fixes
Fixes #5825
Checklist
- [x] Documentation updated
- [x] Changes align with existing API documentation
Hey @adityasah104, I see you have edited the line quite a bit. Why not to keep it as it is and just edit the error message?
As example: Use the json property of the request object to decode the request’s body as JSON. If the body is not valid JSON, or the Content-Type header is not set to application/json, a ~400 Bad Request~ 415 Unsupported Media Type error will be raised.
How about changing it this way? 🙂
@lonelyH3b because that's not accurate, as described in the issue, in the PR description, and in the code.
Yes, got it ❤️
Thanks @davidism for clarifying! The PR is ready for review whenever you have time.
@davidism Just wanted to gently follow up on this when you have a chance. Happy to make any additional changes if needed!