Home > Software design >  Spring boot : REST API behaviour inconsistent post version upgrade
Spring boot : REST API behaviour inconsistent post version upgrade

Time:09-23

I have issue after upgrading to Spring Boot 2.3.0.RELEASE from 1.5.10.RELEASE. Our controller API looks like -

@RequestMapping(value = "/card", method = RequestMethod.GET)
public CardRespDTO getCards(@RequestParam String profileId, @RequestParam(required = false) String banner, @RequestParam(required = false) String paymentGatewayVersion);

Consumer were able to call this API by not passing profileId param but by just providing some USER_ID header. But post the version upgrade, those calls are failing with below error -

org.springframework.web.bind.MissingServletRequestParameterException: Required String parameter 'profileId' is not present

Can someone please help identifying the issue here? We can't ask consumer to make a change.

CodePudding user response:

Marking profileId as not required should do the trick:

@RequestMapping(value = "/card", method = RequestMethod.GET)
public CardRespDTO getCards(@RequestParam(required = false) String profileId, 
    @RequestParam(required = false) String banner, 
    @RequestParam(required = false) String paymentGatewayVersion)
  • Related