travelcc
V2EX  ›  问与答

请教一下各位大佬, feign 接口传递 HttpServletRequest 参数问题

  •  
  •   travelcc · Nov 14, 2024 · 1337 views
    This topic created in 545 days ago, the information mentioned may be changed or developed.

    各位大佬好,碰到一个 feignClient ,接口定义如下, R onMessage(@PathVariable("modelKey") String modelKey, @PathVariable("deviceNo") String deviceNo, HttpServletRequest request);

    现在需要在别的服务通过 feign 调用这个接口,但是无法直接传递 request 过来,报错提示: feign.codec.EncodeException: Error converting request body

    已知接口无法更改,请问大佬们,怎么能把 request 传递过去的,或者用 webclient ,restTemplate 这种呢

    1 replies    2024-11-14 12:54:20 +08:00
    itechify
        1
    itechify  
    PRO
       Nov 14, 2024
    对方拿 HttpServletReuest 干嘛?大概率是获取某些请求头或 response 对象。那个是对方系统自动获取的。你这边设置 null 不传递试试
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   5894 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 59ms · UTC 02:00 · PVG 10:00 · LAX 19:00 · JFK 22:00
    ♥ Do have faith in what you're doing.