Skip to content

Conversation

@adityasah104
Copy link

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

  • Documentation updated
  • Changes align with existing API documentation
Distinguish between 415 Unsupported Media Type (wrong Content-Type)
and 400 Bad Request (invalid JSON body) to align with API documentation.

Fixes #58254
@lonelyH3b
Copy link

lonelyH3b commented Dec 2, 2025

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? 🙂

@davidism
Copy link
Member

davidism commented Dec 2, 2025

@lonelyH3b because that's not accurate, as described in the issue, in the PR description, and in the code.

@lonelyH3b
Copy link

Yes, got it ❤️

@adityasah104
Copy link
Author

Thanks @davidism for clarifying! The PR is ready for review whenever you have time.

@adityasah104
Copy link
Author

@davidism Just wanted to gently follow up on this when you have a chance. Happy to make any additional changes if needed!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

3 participants