Use play.utils.UriEncoding.encodePathSegment to encode path segments.

java.net.URLEncoder.encode does not encode path parameters correctly, while
it is (mostly) sufficient for query parameters. Use a Play API call which
tries to do the right thing, see the API at
http://www.playframework.com/documentation/2.3.x/api/scala/index.html#play.utils.UriEncoding$

Path segment encoding differs from encoding for other parts of a URI. For
example, the "&" character is permitted in a path segment, but has special
meaning in query parameters. On the other hand, the "/" character cannot appear
in a path segment, as it is the path delimiter, so it must be encoded as "%2F".
These are just two examples of the differences between path segment and query
string encoding; there are other differences too.