HttpMediaTypeNotSupportedException: Content type 'application/x-www-form-urlencoded;charset=UTF-8' not supported]
时间: 2023-10-12 12:59:56 浏览: 97
回答: 这个错误是由于后端接收到了一个不支持的Content-Type类型引起的。通常情况下,如果没有明确指定Content-Type类型,默认的Content-Type类型是"application/x-www-form-urlencoded"。而后端通常使用"application/json;charset=utf-8"格式来解析请求,因此导致解析失败。 如果在POST请求中,前端的请求头没有正确指定Content-Type类型或者指定的类型与后端不一致,就会出现这个错误。一种解决办法是检查请求头中的Content-Type属性,确保前端和后端使用的是相同的Content-Type类型。另外,如果前端的POST请求中的body是Json对象,则需要将Content-Type设置为"application/json;charset=utf-8",而不是"application/x-www-form-urlencoded;charset=UTF-8",以避免出现该错误。<span class="em">1</span><span class="em">2</span><span class="em">3</span>
#### 引用[.reference_title]
- *1* [HttpMediaTypeNotSupportedException: Content type ‘application/x-www-form-urlencoded;charset=UTF-8...](https://blog.csdn.net/qq_59312178/article/details/125503841)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v92^chatsearchT0_1"}}] [.reference_item style="max-width: 33.333333333333336%"]
- *2* [问题解决:Content type ‘application/x-www-form-urlencoded;charset=UTF-8‘ not supported](https://blog.csdn.net/qq_42793336/article/details/126636009)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v92^chatsearchT0_1"}}] [.reference_item style="max-width: 33.333333333333336%"]
- *3* [解决:Content type ‘application/x-www-form-urlencoded;charset=UTF-8‘ not supported](https://blog.csdn.net/gongzi_9/article/details/121064210)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v92^chatsearchT0_1"}}] [.reference_item style="max-width: 33.333333333333336%"]
[ .reference_list ]
阅读全文