Is Restlet returning 415 Unsupported Media Type when it should return 400 Bad Request?

萝らか妹 提交于 2019-11-30 21:38:09

415 is correct, as the request is NOT in the right format if it is corrupted in anyway. For example non-parseable JSON or XML. Malformed JSON or XML is NOT JSON or XML by definition, and thus is an unsupported media type, there is no way for Jackson to know that is is supposed to be JSON, it just knows that it isn't JSON that it can parse.

The offical documentation is really clear about this.

10.4.16 415 Unsupported Media Type

The server is refusing to service the request because the entity of the request is in a format not supported by the requested resource for the requested method.

you said, hey this is JSON, and it isn't so the server says, hey, what I got isn't JSON and not supported by this resource.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!