Movatterモバイル変換


[0]ホーム

URL:


  1. 給開發者的 Web 技術文件
  2. HTTP
  3. Reference
  4. HTTP 回應狀態碼
  5. 415 Unsupported Media Type

此頁面由社群從英文翻譯而來。了解更多並加入 MDN Web Docs 社群。

View in EnglishAlways switch to English

415 Unsupported Media Type

HTTP415 Unsupported Media Type用戶端錯誤回應狀態碼表示伺服器拒絕接受請求,因為訊息的內容格式是不受支援的。

格式問題可能是由於請求中指定的Content-TypeContent-Encoding,或是處理請求訊息內容時導致的。有些伺服器對於請求的Content-Type 可能有嚴格的要求。例如,使用UTF8 而非UTF-8 來指定UTF-8 字元編碼可能會導致伺服器認為媒體類型無效。

狀態

http
415 Unsupported Media Type

範例

缺少內容類型

在以下範例中,請求中完全缺少Content-Type 標頭:

http
POST /comments HTTP/1.1Host: example.comContent-Length: 23{"user": "belgin","comment": "LGTM!"}

如果伺服器實作要求該端點的請求至少要有 MIME 類型Content-Type: application/json;,則可能會回應如下:

http
HTTP/1.1 415 Unsupported Media TypeDate: Fri, 28 Jun 2024 12:00:00 GMTServer: Apache/2.4.41 (Ubuntu)Accept-Post: application/json; charset=UTF-8Content-Length: 0

無效的內容類型

在以下範例中,Content-Type 標頭被錯誤地設定為 URL 編碼的表單數據,而實際上內容位於請求主體中:

http
POST /comments HTTP/1.1Host: example.comContent-Length: 23Content-Type: application/x-www-form-urlencoded{"user": "belgin","comment": "LGTM!"}

在這種情況下,伺服器會回應 415,並在Accept-Post 標頭中指明該請求所需的內容類型:

http
HTTP/1.1 415 Unsupported Media TypeDate: Fri, 28 Jun 2024 12:00:00 GMTServer: Apache/2.4.41 (Ubuntu)Accept-Post: application/json; charset=UTF-8Content-Length: 0

規範

Specification
HTTP Semantics
# status.415

參見

Help improve MDN

Learn how to contribute

This page was last modified on byMDN contributors.


[8]ページ先頭

©2009-2026 Movatter.jp