今天使用新的工具ApiPost,調試我的接口,老出錯:
一:錯誤描述:
springboot後端的異常:
[org.springframework.web.HttpMediaTypeNotSupportedException: Content type 'application/octet-stream' not supported]
ApiPost工具端的異常如下:
{
"timestamp": "2020-03-02T09:10:34.256+0000",
"status": 415,
"error": "Unsupported Media Type",
"message": "Content type 'application/octet-stream' not supported",
"path": "/message/wechatTemplate/synchWechatTemplate"
}
二:問題查找
@RequestMapping(value = "/materials",method = RequestMethod.POST )
@ResponseBody
public WebResultInfo collectMetails (@RequestBody ParamsData params)throws GlobalException {
logger.info("code runing -->> 001 --- materials ");
logger.info("param : {} " , params.toString() );
return WebResultInfo.success() ;
}
沒什麼問題呀,百度了一下,都說要刪除 @RequestBody ,腦子瓦特了 我是JSON傳輸的數據,讓我刪除!
三:解決問題
回想一下http請求的幾種數據格式,腦子瀕臨崩潰時記起,Header 也是需要定義的,唉 自動化工具用久了,退化了