Как изменить данные пользователя с помощью API SAP BOBJ REST? - PullRequest
0 голосов
/ 03 мая 2020

Я пытаюсь изменить данные пользователя в системе SAP BusinessObjects / Business Intelligence с помощью RESt API с помощью SAP Guide . Но получается ошибка ниже. Я использую APPLICATION_ JSON в качестве ContentType. Пожалуйста, укажите мне, если я делаю что-то не так здесь.

org.springframework.web.client.HttpClientErrorException$BadRequest: 400 Bad Request

Поля класса сущности UserDetails:

`

private String cuid;
private String name;
private String description;
private String id;
private String fullname;
private String type;
private String ownerid;
private String updated;
private String parentid;

//user details
private boolean forcepasswordchange;
private String parentcuid;
private boolean nameduser;
private boolean disabled;
private String email;
private boolean passwordexpire;

private int inbox; 

`

Код для вызова API:


RestTemplate restTemplate = new RestTemplate();
        HttpHeaders headers = new HttpHeaders();
        headers.setContentType(MediaType.APPLICATION_JSON);
        headers.setAccept(Arrays.asList(MediaType.APPLICATION_JSON));
        headers.add("x-sap-logontoken", token);
        HttpEntity<UserDetails> entity = new HttpEntity<>(user, headers);
        ResponseEntity<String> response = null;
        try{
            String baseUrl=createBaseUrl(sysVO.getHostName(),sysVO.getPortNr());
            //restTemplate.put(baseUrl.concat(Info.BOBI_USER_DETAILS_URL+user.getId()), entity, String.class);
            response = restTemplate.exchange(baseUrl.concat(Info.BOBI_USER_DETAILS_URL+user.getId()), HttpMethod.PUT, entity, String.class);

            HttpStatus httpStatus = response.getStatusCode();
            if(httpStatus.is2xxSuccessful()) {
                System.out.println("modified User");
            }else{
                System.out.println("not modified");
            }
        }catch (Exception e) {
            e.printStackTrace();
            throw new RuntimeException(e.getMessage(), e);
        }
...