Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

I try to access a rest endpoint by using springs RestTemplate.getForObject() but my uri variables are not expanded, and attached as parameters to the url. This is what I got so far:

Map<String, String> uriParams = new HashMap<String, String>();
uriParams.put("method", "login");
uriParams.put("input_type", DATA_TYPE);
uriParams.put("response_type", DATA_TYPE);
uriParams.put("rest_data", rest_data.toString());
String responseString = template.getForObject(endpointUrl, String.class, uriParams);

the value of the endpointUrl Variable is http://127.0.0.1/service/v4_1/rest.php and it's exactely what it's called but I'd expect http://127.0.0.1/service/v4_1/rest.php?method=login&input_type... to be called. Any hints are appreciated.

I'm using Spring 3.1.4.RELEASE

Regards.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
237 views
Welcome To Ask or Share your Answers For Others

1 Answer

There is no append some query string logic in RestTemplate it basically replace variable like {foo} by their value:

http://www.sample.com?foo={foo}

becomes:

http://www.sample.com?foo=2

if foo is 2.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...