I am using a spring boot application that calls a rest api from openFire in order to create a user for a chat. This is the code which is using the rest api client:

public class GetUsersOpenFireProcessor implements Processor{

    public void process(Exchange xchg) throws Exception {
        
        
        // Customer ID
        String customerKey = "admin";
        // Customer secret
        String customerSecret = "pass";

        // Concatenate customer key and customer secret and use base64 to encode the concatenated string
        String plainCredentials = customerKey + ":" + customerSecret;
        String base64Credentials = new String(Base64.getEncoder().encode(plainCredentials.getBytes()));
        // Create authorization header
        String authorizationHeader = "Basic " + base64Credentials;
        
         OpenFireClass user= new OpenFireClass();

            user.setEmail("[email protected]");
            user.setFirstname("dany");
            user.setPassword("p@ssw0rd");
            user.setUsername("danyab");

            //UserCreationResponse response=new UserCreationResponse();

            RestTemplate restTemplate = new RestTemplate();
            
            MultiValueMap<String, String> headers = new LinkedMultiValueMap<String, String>();
            headers.add("Authorization", authorizationHeader);
            headers.add("Content-Type", "application/json");
            headers.add("Accept", "application/json");

            String uri = "http://localhost:9090/plugins/restapi/v1/users";
            restTemplate.getMessageConverters().add(new MappingJackson2HttpMessageConverter());
            HttpEntity<OpenFireClass> requestObject = new HttpEntity<OpenFireClass>(user, headers);
           ResponseEntity<String> responseEntity=restTemplate.postForEntity(uri, requestObject,String.class);
           xchg.getIn().setBody(responseEntity);
   
 
    
}}

however I am getting this error: org.springframework.web.client.HttpServerErrorException$InternalServerError: 500 Server Error: [no body]

I am using the openfire server for chatting. So any idea how to solve this issue?Thank you

0

There are 0 best solutions below