1

I am very new to spring boot.

have a spring boot application with a GET service.

@RequestMapping(value = "/abc/track/{type}", method = RequestMethod.GET)

    public void DummFunc(                            
          @RequestParam(value="subs", required = false) String sub,
,  HttpServletResponse response) {}

If I pass following as value to parameter subs

{%22endpoint%22:%22https://def.abc.com/tyu/send/eD3vpGNQW28:APA91bHOo8rYrV0xccdQz3okjZJG-QGrJX8LG6ahJnEUpMNfGedqi3hJxQsJx_8BMbH6oDjaSPPEXqzNWchWrGSkhuTkSdemikkys1U22Ipd7MsRw0owWbw89V2fslIVAJ6G5lkyvYuQ%22,%22expirationTime%22:null,%22keys%22:{%22p256dh%22:%22BK0pktn50CMsTQtqwdPlKlJtdFs0LFeXX14T1zgoz6QWnvSTp5dxtChnUP5P1JX0TsjcopbdPKyN31HfABMUyic%22,%22auth%22:%22qbO_z0vGao9wD-E5g8VU-A%22}}

It fails to capture the request and control does not come inside of the function.

If we instead pass as value to parameter subs:

%7B%22endpoint%22:%22https://def.abc.com/tyu/send/dX5q5eV7hFQ:APA91bHib-0QXrMzjatcvTR_uaIeeJK8lf6GmXUC9Jxv0Oxth-BzD4GmWnd4-YpDZv8qSFZ0eSg9mB2YkRvkc5ezdXW5KeaHjuQZfdyDxyBXjJgE-25Xbtlk37pdm8vfLk20k0k_VxW9%22,%22expirationTime%22:null,%22keys%22:%7B%22p256dh%22:%22BCCvcBLpRqp4u0auP688_MUJLsAiwWlQSn5kpyl8YVsEo_J-KpSdnhCmVIE_BhDXBcFYflPK52hqhYf3EaOCyuY%22,%22auth%22:%22iKuW_ESkCZnubWcQu_JK8w%22%7D%7D

It works fine.

To fix the issue, I added following in application.properties

spring.http.encoding.charset=UTF-8
spring.http.encoding.enabled=true
spring.http.encoding.force=true

Also, added a bean to my main class

@Bean
    public CharacterEncodingFilter characterEncodingFilter() {
        System.out.println("character encoding filter called");
        CharacterEncodingFilter characterEncodingFilter = new CharacterEncodingFilter();
        characterEncodingFilter.setEncoding("UTF-8");
        characterEncodingFilter.setForceEncoding(true);
        characterEncodingFilter.setForceRequestEncoding(true);
        return characterEncodingFilter;
    }

Also, I tried using @Encoded from

https://www.concretepage.com/webservices/resteasy-3/rest-web-service-jax-rs-encoded-annotation-example-with-resteasy-3

None of these have resolved the issue.

If I use postman chrome app as client, it returns 400 and so does If I hit this api from browser. Latest version of postman however returns 200.

If I look at the request http code in postman, the new version of postman has { in request as it and chrome app of postman shows %7B .

If in my requests I replace { with %7B myself, it works fine. how do I fix this in my spring boot application?

systemdebt
  • 4,589
  • 10
  • 55
  • 116
  • 1
    Possible duplicate of [How to handle curly braces in RequestParam in spring boot](https://stackoverflow.com/questions/54005532/how-to-handle-curly-braces-in-requestparam-in-spring-boot) – smilyface Jan 04 '19 at 12:20

0 Answers0