http 响应415状态码
http 响应415状态码
现象
$bash uat-gray-id.sh {"timestamp":"2024-06-12 13:55:25","status":415,"error":"Unsupported Media Type","message":"","path":"/ecommerce"}
脚本内容
$cat uat-gray-id.sh #!/bin/bash #**************************************************************************************** #Author: wei #*************************************************************************************** curl --location --request POST 'http://172.31.0.5:32080/ecommerce' \ -d '{ "enterpriseIds": [11290], "tenantIds": [43370163176] }'
故障分析
http 415状态码表示“不支持的媒体类型”(unsupported media type)。这意味着客户端在请求中发送的内容类型(如请求体中的json数据),服务器无法理解或不支持。通常,这是因为请求头中的content-type设置不正确,或者服务器端没有配置为处理该类型的内容。要解决这个问题,您需要确保请求头中的content-type与实际发送的数据类型相匹配,并且服务器支持这种数据类型。
解决方案
指定请求头的content-type,再次执行成功。
$cat uat-gray-id.sh #!/bin/bash #**************************************************************************************** #Author: wei #*************************************************************************************** curl --location --request POST 'http://172.31.0.5:32080/ecommerce' \ -H 'Content-Type: application/json' \ -d '{ "enterpriseIds": [11290], "tenantIds": [43370163176] }'
$bash uat-gray-id.sh
{"code":"200","message":"请求成功","data":{"enterpriseIds":["11290","483"],"tenantIds":["43370163176","41151612093"]}}
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】凌霞软件回馈社区,博客园 & 1Panel & Halo 联合会员上线
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】博客园社区专享云产品让利特惠,阿里云新客6.5折上折
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· CSnakes vs Python.NET:高效嵌入与灵活互通的跨语言方案对比
· DeepSeek “源神”启动!「GitHub 热点速览」
· 我与微信审核的“相爱相杀”看个人小程序副业
· Plotly.NET 一个为 .NET 打造的强大开源交互式图表库
· 上周热点回顾(2.17-2.23)