java - Cannot send a GET request with RESTTemplate -
i need send request following
http://server.com/server1/index.php?id=123&name=jack&date=12.1.2016
i using following code seems not send correct request response object empty. wondering how show complete url resttemplate sending? know wireshark can used there way retrieve using resttemplate?
code
string url = "http://server.com/server1/index.php?" map<string,string> vars = new hashmap<string,string>(); vars.put("id","123"); vars.put("name","jack"); vars.put("date","12.1.2016"); profile profile = resttemplate.getforobject(url,profile.class,vars);
you can set log level org.springframework.web.client.resttemplate
debug you'll output similar this:
12:11:22.072 [main] debug o.s.web.client.resttemplate - created request "http://echo.jsontest.com/key/value/one/two"
12:11:22.110 [main] debug o.s.web.client.resttemplate - setting request accept header [application/json, application/*+json]
12:11:24.492 [main] debug o.s.web.client.resttemplate - request "http://echo.jsontest.com/key/value/one/two" resulted in 200 (ok)
12:11:24.494 [main] debug o.s.web.client.resttemplate - reading [class com.example.testoptional$echo] "application/json;charset=iso-8859-1" using [org.springframework.http.converter.json.mappingjackson2httpmessageconverter@16f7c8c1]
there can see request url , returned http status code.
if using logback xml configuration write
<logger name="org.springframework.web.client.resttemplate" level="debug" />
Comments
Post a Comment