Skip to content
Advertisement

RestTemplate: How to send URL and query parameters together

I am trying to pass path param and query params in a URL but I am getting a weird error. Below is the code.

JavaScript

and my url is becoming http://test.com/Services/rest/%7Bid%7D/Identifier?name=myName

What should I do to make it work? I am expecting http://test.com/Services/rest/{id}/Identifier?name=myName so that params will add id to the url.

Advertisement

Answer

I would use buildAndExpand from UriComponentsBuilder to pass all types of URI parameters.

For example:

JavaScript
User contributions licensed under: CC BY-SA
4 People found this is helpful
Advertisement