Search code examples
spring-bootrequest-mappinghttp-request-parametersget-mapping

How to make Get Request with Request param in Postman


I have created an endpoint that accepts a string in its request param

@GetMapping(value = "/validate")
    private void validateExpression(@RequestParam(value = "expression") String expression) {
        System.out.println(expression);
        // code to validate the input string
    }

While sending the request from postman as

https://localhost:8443/validate?expression=Y07607=Curr_month:Y07606/Curr_month:Y07608 

// lets say this is a valid input console displays as

Y07607=Curr_month:Y07606/Curr_month:Y07608 Valid

But when i send

https://localhost:8443/validate?expression=Y07607=Curr_month:Y07606+Curr_month:Y07608

//which is also an valid input console displays as

Y07607=Curr_month:Y07606 Curr_month:Y07608 Invalid

I am not understanding why "+" is not accepted as parameter.

"+" just vanishes till it reaches the api! Why?


Solution

  • I didn't find any solution but the reason is because + is a special character in a URL escape for spaces. Thats why it is replacing + with a " " i.e. a space.

    So apparently I have to encode it from my front-end