1

I am implementing REST web API. Some data is in request body as JSON, some other into URL itself, e.g. http://myhost/webapp/api/series/GMT/OTHER-DATA.

The key parameter here is GMT that is the timezone identifier. The problem happens when time zone identifier contains slash, e.g. Europe/London. Since slash is a special character I encoded the parameter, so I got http://myhost/webapp/api/series/Europe%2FLondon/OTHER-DATA.

And my (web) client failed to reach server and got 404. I changed method from POST to get and saw that everything works fine.

Since I have to use POST here I found some ugly work-around for now but it is interesting to know why does it happen?

I am using Spring MVC but I do not think it is relevant here: I tried to put breakpoint into Spring's DispatcherServlet and in several Spring's HTTP filters that are usually invoked when everything is going well and I did not see that even one of them is called when URL contains %2F.

I did yet another experiment. I tried to use %20 (space) instead and saw that it works fine with GET and does not work with POST.

I'd be appreciate to know if there is a "good" solution for the problem?

AlexR
  • 114,158
  • 16
  • 130
  • 208
  • 1
    Check this answer out, it gives you a better way to use POST: http://stackoverflow.com/questions/4330392/on-android-make-a-post-request-with-url-encoded-form-data-without-using-urlenco – Alex van den Hoogen Dec 21 '11 at 23:52
  • Thank you, @ Alex van den Hoogen (+1). Unfortunately this does not help me: I cannot change client and have to find a server-side fix. – AlexR Dec 22 '11 at 08:26
  • Can you describe your technology stack - ie Apache, Tomcat, etc. Encoded slashes are often disabled by default since they pose a security risk. – johnstok Dec 22 '11 at 15:28

0 Answers0