如何解决下面的代码,得到“ 400 Bad Request”?

时间:2019-04-06 14:34:42

标签: rest web-services spring-boot resttemplate bad-request

@GetMapping("/user")
public ResponseEntity<?> getRoleKey() {

String transactionUrl = "http://localhost:8080/user?_queryFilter={value}";
UriComponents builder=  UriComponentsBuilder.fromUriString(transactionUrl).buildAndExpand("name+eq+%22test%22");

try {
HttpHeaders headers = uan.createHttpHeaders("userId", "password");

HttpEntity<String> requestEntity = new HttpEntity<String>(headers);
ResponseEntity<Result> response = restTemplate.exchange(builder.toUriString(), HttpMethod.GET, requestEntity, Result.class);

return new ResponseEntity<String>(response.getBody().getId(), HttpStatus.OK);
        }
catch (Exception eek) {
return new ResponseEntity<String>(eek.toString(), HttpStatus.OK);

        }   
    }

我正在努力解决此问题,请帮助我解决此问题。 我做了多次更改,但仍然收到“ 400错误的请求”。

0 个答案:

没有答案