前言
如题,feign + post请求,报错403;
解决思路
一天一天的百度,一遍一遍测试
还是不行,问群里没人回。
或者是交易都不行
有人说了,但是他的方法可以,到我这边就不行了。他用的是restTemplate,是这样传参的,通过requestHead
有人说可以用RequestInterceptor 替代requestHead。
下面是feign的测试思路
/**
* 根据用户ID查询资源列表
* @param userId
* @return
*/
@RequestMapping(value = "/queryBasePrivilegeByUserId", method = RequestMethod.POST, produces = "application/json; charset=UTF-8")
List<BasePrivilege> queryBasePrivilegeByUserId(@RequestHeader("userId") Integer userId, String testStr1, @RequestParam("testStr2") String testStr2);
每种我都试一遍,看看哪个能传过去。
下面是服务端控制台:
也就是说通过requestparam可以获取到。但是我开始就是这么写的,报了403。
打包,重启测试:
解决办法
解决办法见下篇文章