Could not extract response: no suitable HttpMessageConverter found for content type [application/octet-stream]

9.7k Views Asked by At

I am making a simple Rest call as below with no headers in java. But I get this exception message: Could not extract response: no suitable HttpMessageConverter found for response type [class com.things.customer.xcitycustomers.responsemodel.CustomerDetailsGrp1Request] and content type [application/octet-stream]\n\tat

ResponseEntity<CustomerDetailsGrp1Request> response
                = restTemplate.getForEntity("http://localhost:8089/mock/group1", CustomerDetailsGrp1Request.class, HttpStatus.OK);

I am not sure how/why is content type of application/octet-stream is being passed. I tried adding content type as application/json in postman header and in request entity too but it doesnot help. Also tried adding @bean to enable all content type but did not work either. Any help please! Thanks in advance

1

There are 1 best solutions below

0
On

My solution was: In the mocker server I have not specified the content type, so it was giving me octatte-stream. Once I mentioned the content type as :

 "response": {
    "status": 200,
    "bodyFileName": "../__files/get_users_response.json",
    "headers": {
      "Content-Type": "application/json"
    }
  }

Bingo! It is working.