HttpClientErrorException:400错误的请求,但是邮递员得到了响应

时间:2018-10-16 05:33:42

标签: spring rest web-services resttemplate

当我使用RestTemplate时,我收到400错误的请求,但是当我使用邮递员客户端时,下面的响应是我的代码示例:

String url =  "https://fastaglogin.icicibank.com/ISRCUSTAPI/Customer/GetTransactionDetails";
    RestTemplate    restTemplate    = new RestTemplate();
    HttpHeaders headers = new HttpHeaders();
    headers.set("APIClient_ID", "1*******9");
    headers.set("API_KEY", "AE90****************89");
    headers.setContentType(MediaType.APPLICATION_JSON);
    MultiValueMap<String, String> map = new LinkedMultiValueMap<String, String>();
    map.add("CustomerId", "10******59");
    map.add("VehicleNumber", "KA51AA6117");
    map.add("StartTransactionDate", "2018-10-01");
    map.add("EndTransactionDate", "2018-10-16");

    final HttpEntity<MultiValueMap<String, String>> entity = new HttpEntity<MultiValueMap<String, String>>(map ,
            headers);

     ResponseEntity<String> result = restTemplate.exchange(url, HttpMethod.POST, entity, String.class);

enter image description here

0 个答案:

没有答案