I have to make a REST
call that includes custom headers and query parameters. I set my HttpEntity
with just the headers (no body), and I use the RestTemplate.exchange()
method as follows:
HttpHeaders headers = new HttpHeaders();
headers.set("Accept", "application/json");
Map<String, String> params = new HashMap<String, String>();
params.put("msisdn", msisdn);
params.put("email", email);
params.put("clientVersion", clientVersion);
params.put("clientType", clientType);
params.put("issuerName", issuerName);
params.put("applicationName", applicationName);
HttpEntity entity = new HttpEntity(headers);
HttpEntity<String> response = restTemplate.exchange(url, HttpMethod.GET, entity, String.class, params);
This fails at the client end with the dispatcher servlet
being unable to resolve the request to a handler. Having debugged it, it looks like the request parameters are not being sent.
When I do a an exchange with a POST
using a request body and no query parameters it works just fine.
Does anyone have any ideas?
Question&Answers:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…