请求接口返回415-大神帮忙解决


post满请求接口入参

curl -X POST \
  http://localhost:8082/api/dailyPaper/sendDailyPaper \
  -H 'Content-Type: application/json' \
  -H 'Postman-Token: ca48584b-e58d-48fb-88c8-794af5f76a76' \
  -H 'cache-control: no-cache' \
  -d '{
    "bccAddress":"",
    "ccAddress":"",
    "id":0,
    "mailContentBody":{
        "bugSituation":"",
        "keyPoint":{
            "developmentTime":"2021-04-01",
            "planCommitTime":"2021-04-01",
            "planIntegrationTime":"",
            "planOnlineTime":"2021-04-01",
            "planTestEndTime":"2021-04-01",
            "planTestGrayTime":"",
            "planTestStartTime":"",
            "state":0,
            "type":""
        },
        "principal":{
            "productLeader":"",
            "technicalLeader":"",
            "testLeader":""
        },
        "progress":{
            "progress":"",
            "status":"已关闭",
            "tastDays":0,
            "testDuration":"0.3",
            "url":""
        },
        "question":"",
        "risk":"",
        "status":"已关闭",
        "subtasksDetails":[
            {
                "dev":"",
                "fe":"杨倩倩",
                "objectName":"H5页面--露出【专用发票】入口+修改文案",
                "planCommitTime":"2021-04-01",
                "planOnlimeTime":"2021-04-01",
                "pmoId":"TOB-529",
                "qa":"刘天华(tianhual_1)",
                "state":"已关闭",
                "testSchedule":"",
                "url":""
            },
            {
                "dev":"",
                "fe":"甘明阳",
                "objectName":"订单后台-前端恢复纸质专票选项",
                "planCommitTime":"2021-04-01",
                "planOnlimeTime":"2021-04-01",
                "pmoId":"TOB-534",
                "qa":"刘天华(tianhual_1)",
                "state":"已关闭",
                "testSchedule":"",
                "url":""
            }
        ],
        "welcomes":{
            "dateTestCompletion":"2021-04-01",
            "estimatedPublication":"2021-04-01",
            "numberDaysItems":0,
            "objectCount":2,
            "objectName":"纸质专票入口放开展示"
        }
    },
    "pmoId":"TOB-469",
    "sendTime":null,
    "status":"已关闭",
    "subject":"纸质专票入口放开展示",
    "toAddress":"15801631294@163.com"
}'

对应实体类
public class MailContentBody implements Serializable {
private String status;
private Welcomes welcomes;
private Progress progress;
private String risk;
private String question;
private List subtasksDetails;
private String bugSituation;
private PmoKeyPoint pmoKeyPoint;
private Principal principal;

错误信息
<!doctype html>HTTP状态 415 - 不支持的媒体类型body {font-family:Tahoma,Arial,sans-serif;} h1, h2, h3, b {color:white;background-color:#525D76;} h1 {font-size:22px;} h2 {font-size:16px;} h3 {font-size:14px;} p {font-size:12px;} a {color:black;} .line {height:1px;background-color:#525D76;border:none;}

HTTP状态 415 - 不支持的媒体类型


类型 状态报告

描述 源服务器拒绝服务请求,因为有效负载的格式在目标资源上此方法不支持。


Apache Tomcat/8.5.64

对应具体返回的错误信息贴出来一下吧~

已经贴出来了

对应这个请求,在抓包工具内抓包看下是否可以正常拿到返回报文呢

produces = {"application/json;charset=UTF-8"}

重写了个实体类做入参,感觉就是之前层数太多,默认配置应该是不允许那么多层数,或者tomcat本身的配置

你抓包分析下吧,先看看原始的请求是什么,大概率是header有错误,或者你的body里格式不正确。