I want to call a web service which takes in url a query parametre. This is the query :
{PK} IN({{Select {o.name} from {Student! as o} where {o.name} IN ({{Select {s.pk}
from {School as s} where {s.code}="school"}})}})
I encode the query using this
And i put the encoded query in web service url : http://host?query=query_above_encoded.
So when a do this (call the web service using resttemplate
):
ResponseEntity<Model> response = restTemplate.exchange(
url, HttpMethod.GET, request, Model.class);
I get this exception :
org.springframework.web.client.HttpServerErrorException: 500 Erreur Interne de Servlet
But when I call the same url using a rest client app (as Postman) a get the response.
Does anyone have any ideas?
The solution is to use URI JAVA object after encoding the url:
ResponseEntity<Model> response = restTemplate.exchange(
new URI(encodedUrl), HttpMethod.GET, request, Model.class);
Hope this help someone else.