HTTP请求415错误 – 不支持的媒体类型(Unsupported media type)
2017-08-18 15:50
731 查看
HTTP请求415错误 – 不支持的媒体类型(Unsupported media type)
通常有以下情况:
1:检查你的 http 请求头信息,比如 因为 User-Agent 被服务器设置 拒绝请求了;
比如你写的的爬虫,就很有可能因为没有伪装成浏览器,被拒绝请求
user-agent 详情
2:查看你的 http 请求方法,以及服务器端的设置
比如:有一个 强制用 post 请求的接口,你是不是用了非post 请求
3:post 请求参数设置,是不是必须的,json 格式
比如下面,两段代码,
如下 json参数,body
![](https://oscdn.geek-share.com/Uploads/Images/Content/202004/05/c928380259a3628cd6999cf0ccf4970e.png)
如下 form 格式 参数
通常有以下情况:
1:检查你的 http 请求头信息,比如 因为 User-Agent 被服务器设置 拒绝请求了;
比如你写的的爬虫,就很有可能因为没有伪装成浏览器,被拒绝请求
user-agent 详情
2:查看你的 http 请求方法,以及服务器端的设置
比如:有一个 强制用 post 请求的接口,你是不是用了非post 请求
3:post 请求参数设置,是不是必须的,json 格式
比如下面,两段代码,
如下 json参数,body
import requests import json payload={"userName":"names","userCode":"123456","phoneNum":"7800","regPic":"picData"} headers={‘content-type‘: ‘application/json‘} burl="http://httpbin.org/post" r=requests.post(burl, data=json.dumps(payload), headers=headers) print r.text
![](https://oscdn.geek-share.com/Uploads/Images/Content/202004/05/c928380259a3628cd6999cf0ccf4970e.png)
如下 form 格式 参数
import requests import json payload={"userName":"names","userCode":"123456","phoneNum":"7800","regPic":"picData"} headers={‘content-type‘: ‘application/json‘} burl="http://httpbin.org/post" r=requests.post(burl, data=payload, headers=headers) print r.text
![](https://oscdn.geek-share.com/Uploads/Images/Content/202004/05/9a8ac94aa08c55e040c44ebf5a7f8aa8.png)
相关文章推荐
- 22、HTTP请求415错误 – 不支持的媒体类型(Unsupported media type)
- HTTP请求415错误 – 不支持的媒体类型(Unsupported media type)
- HTTP 415 错误 – 不支持的媒体类型(Unsupported media type)
- ajax,Unsupported media type-415(不 支持的媒体类型)
- RestTemplate远程调用POST请求:HTTP 415 Unsupported Media Type
- SpringMVC 中HttpMessageConverter简介和Http请求415 Unsupported Media Type的问题
- SpringMVC 中HttpMessageConverter简介和Http请求415 Unsupported Media Type的问题
- 【JavaScript】SpringMVC Http请求415 Unsupported Media Type的问题
- SpringMVC 中HttpMessageConverter简介和Http请求415 Unsupported Media Type的问题
- SpringMVC 中HttpMessageConverter简介和Http请求415 Unsupported Media Type的问题
- SpringMVC 中HttpMessageConverter简介和Http请求415 Unsupported Media Type的问题 对比项目用的
- postman报415(Unsupported Media Type)不支持的类型异常
- SpringMVC 中HttpMessageConverter简介和Http请求415 Unsupported Media Type的问题
- JS —— Http unsupported media type 415 错误
- SpringMVC 中HttpMessageConverter简介和Http请求415 Unsupported Media Type的问题
- HTTP Status 415 Unsupported Media Type [Spring MVC @RequestBody传递Json数据 ]
- Http status 415 Unsupported Media Type
- HTTP/1.1 415 Unsupported Media Type
- HTTP Status 415 - Unsupported Media Type
- HTTP Error 415: Unsupported Media Type! 这个错误