返回顶部

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"]}}

 

posted @ 2024-06-12 14:18  九尾cat  阅读(82)  评论(0编辑  收藏  举报