How to properly escape a URL to be used in RestTemplate that has flower brackets (JSON)

802 Views Asked by At

Here's my URL that I need to feed in to RESTTemplate.

http://myurl.com/items?select=itemCode,itemType,code&criteria={"uniquecriteriaId":"2055"}

I need to replace 2055 with whatever the User sends in. The problem is that I'm not able to properly encode the URL as it has those flower brackets, intentional double quotes. How can I construct this URL for properly inputting it to the RestTemplate. Let's say that the user sent value for the "2055" above is stored in

String id="2055";

My RestTemplate query looks something like this

rt.getForEntity(url, List.class);
0

There are 0 best solutions below