Use of character ';' in delete API path variable value

158 Views Asked by At

Path variable = "476%3B"

In a delete API, in path variable value, the character ';' is included in Id and is encoded as '%3B' The id is passed as a string and later on in the app, it is parsed as an integer using Integer.parseInt("476%3B") When this Id value goes thru the API gateway, somehow, the character ';' is getting stripped and using "476" instead of "476%3B" for Id. On execution of the app, I am expecting http code 400 (bad request) But I am getting 404 (not found) The Id can only be integer. Can someone explain the reason behind this?

1

There are 1 best solutions below

0
ILya Cyclone On

You could look at this UrlPathHelper::setRemoveSemicolonContent. By default it is true.

Remove ";" (semicolon) content from the given request URI

https://docs.spring.io/spring-framework/docs/current/javadoc-api/org/springframework/web/util/UrlPathHelper.html#removeSemicolonContent(java.lang.String)

And you can configure it.

@Configuration
public class WebConfig implements WebMvcConfigurer {

    @Override
    public void configurePathMatch(PathMatchConfigurer configurer) {
        UrlPathHelper urlPathHelper = new UrlPathHelper();
        urlPathHelper.setRemoveSemicolonContent(false);
        configurer.setUrlPathHelper(urlPathHelper);
    }
}