I have a path that looks like this: `/service/method/{id}/{parameters}` which I call using restTemplate, where `/service/method` is a microservice, `{id}` is some id that I need to ask for, and `{parameters}` is a link that looks something like this: `/home/floor/kitchen/` that I use for mapping in a JsonNodeTree later in the service/method microservice. 

I am trying to use

```
    Map<String, String> uriVariables = new HashMap<String, String>();
            uriVariables.put("id", "5080572115");
            uriVariables.put("parameters", "/home/floor/kitchen/");

            UriComponents uriComponents = UriComponentsBuilder.newInstance().scheme("http").host("service/methods/{id}").
            path("/{parameters}").buildAndExpand(uriVariables).encode();
String finalURI = uriComponents.toUriString();
return restTemplate.getForObject(finalURI, Integer.class);

```

But what I get is the whole link <http://service/methods/>{id}/{parameters} encoded. And what I need is only a portion of it ({parameters}) to be encoded so I can parse the other part of the url into the RestTemplate. 
To be clear again, I need to parse service/methods/{id} into RestTemplate, and decode {parameters} later to use as a path for the JsonNodeTree.

edit: I am aware of queries but couldn’t find a solution of encoding a portion of a path.