put 请求Content type 'application/x-www-form-urlencoded;charset=UTF-8' not supported
时间: 2023-09-20 17:14:13 浏览: 156
这个问题出现的原因是后台需要接收的数据格式是json格式,而你使用的是表单数据格式。\[2\]解决方法是将传递的数据改为json格式。你可以使用OkHttp的RequestBody类来创建一个json格式的请求体,然后将其传递给后台。例如,你可以使用以下代码来创建一个json格式的请求体:
```java
RequestBody body = RequestBody.create(MediaType.parse("application/json; charset=utf-8"), new JSONObject()
.put("username", "test01")
.put("password", "123456")
.toString());
```
然后将这个请求体作为参数传递给你的PUT请求。这样就可以解决"Content type 'application/x-www-form-urlencoded;charset=UTF-8' not supported"的问题了。\[2\]
#### 引用[.reference_title]
- *1* [关于出现“Content type ‘application/x-www-form-urlencoded;charset=UTF-8‘ not supported“问题如何...](https://blog.csdn.net/LoveTrainHY/article/details/122405744)[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^v91^insertT0,239^v3^insert_chatgpt"}} ] [.reference_item]
- *2* [“Content type ‘application/x-www-form-urlencoded;charset=UTF-8‘ not supported](https://blog.csdn.net/syfyyds12138/article/details/127056288)[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^v91^insertT0,239^v3^insert_chatgpt"}} ] [.reference_item]
- *3* [HTTP请求方法之POST请求的三种常见数据提交格式](https://blog.csdn.net/sunyctf/article/details/129053163)[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^v91^insertT0,239^v3^insert_chatgpt"}} ] [.reference_item]
[ .reference_list ]
阅读全文