You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
How to implement endpoints for specific content-types #1584
How to implement endpoints for specific content-types
Checklist
Dependencies installed
No typos
Searched existing issues and docs
Expected behaviour
I've have an PATCH endpoint which only accepts requests with content-type application/merge-patch+json
Actual behaviour
Not sure how to implement it
Details
I'm currently trying to create an endpoint which supports the https://tools.ietf.org/html/rfc7396 standard for patching resources.
But im struggling right now how to implement the specific content-type i want to accept.
So every request without the content-type to be set to application/merge-patch+json should be rejected with at 415.
My two ideas are the following:
In the handler function i just check the header manually and reject it with 415 if the content-type does not match
or what i've found here so far
Create custom binder to bind the data which only accepts the specific content-type
I guess the second approach is the better but i'm not sure if there is maybe another solution or what should be prefered?
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
Activity
mymtw commentedon Jun 10, 2020
think that you should check both
stale commentedon Aug 9, 2020
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
eloo commentedon Aug 10, 2020
for the record:
i'm now using the following snippet for this use-case:
and something like this in the endpoint handler
maybe this can be adapted and added as an example to the documention?
stale commentedon Nov 7, 2020
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
lyda commentedon Jan 6, 2024
I submitted PR #2572 which would fix this issue.
vishr commentedon Jun 13, 2026
This has been answered above and is labeled
wontfix. Closing to tidy the tracker — thanks all for the discussion. 🙏