请求中未接受的Content-Type的HTTP状态代码 [英] HTTP status code for unaccepted Content-Type in request

查看:295
本文介绍了请求中未接受的Content-Type的HTTP状态代码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

对于某些资源,我的RESTful服务器只接受带有JSON对象作为内容主体的 PUT POST 请求,因此需要 Content-Type application / json 而不是 application / x-www- form-urlencoded multipart / form-data 或其他任何内容。

For certain resources, my RESTful server only accepts PUT and POST requests with JSON objects as the content body, thus requiring a Content-Type of application/json instead of application/x-www-form-urlencoded or multipart/form-data or anything else.

格式错误的JSON (或缺少)返回 400 ,其中的错误消息直接来自JSON解析器引发的异常,用于调试目的。

Malformed JSON (or lack thereof) returns a 400 with the error message taken directly from the exception raised by the JSON parser, for debugging purposes.

哪个HTTP错误代码意味着客户端发送了具有不可接受的 Content-Type 的请求,即使服务器可以在技术上解析请求内容?

Which HTTP error code means that the client sent a request with an unacceptable Content-Type, even if the server could technically parse the request content?

推荐答案

根据此列表,它可能是 415不支持的媒体类型 http://www.w3.org/Protocols/rfc2616/rfc2616-sec10。 HTML#sec10.4.16

It could be 415 Unsupported Media Type according to this list: http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.4.16.

这篇关于请求中未接受的Content-Type的HTTP状态代码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆