我正在使用Gitlab的API,对于某些端点,您有两个变量,例如https://gitlab.example.com/api/v4/projects/:id/members/:user_id projectId和userId是我要添加到url中的变量。
我试图在restTemplate exchange()中使用多个uriVariables。
当我有一个变量时我一直在做
@Override
public User getUser(String userId){
ResponseEntity<User> respEntity = restTemplate.exchange(userURL, HttpMethod.GET,getHeader(), User.class, userId );
User user = respEntity.getBody();
return user;
}
userURL = https://gitlab.com/api/v4/users/ {userid}
现在对两个变量执行此操作
@Override
public User getUserFromProject(String userId, String projectId){
ResponseEntity<User> respEntity = restTemplate.exchange(URL, HttpMethod.GET,getHeader(), User.class, projectId,userId );
User user = respEntity.getBody();
return user;
}
URL = https://gitlab.com/api/v4/projects/ {projectId} / members / {userId}
引发此错误
org.springframework.web.client.HttpClientErrorException $ BadRequest: 400错误请求 org.springframework.web.client.HttpClientErrorException.create(HttpClientErrorException.java:79) 〜[spring-web-5.1.6.RELEASE.jar:5.1.6.RELEASE]
谢谢。