title: RestClientException: Could not write request: no suitable HttpMessageConverter found for request type
body: <p>I am trying to send a POST request to REST service using RestTemplate but getting below error </p>
  
  <blockquote>
    <p>RestClientException: Could not write request: no suitable HttpMessageConverter found for request type [xxx.query.XBrainQueryRequest] and and content type [application/json].</p>
  </blockquote>
  
  <pre><code>XBrainQueryRequest request = new XBrainQueryRequest();
  // set query ID
  request.setQueryId(XBrainTradequeryId);
  request.setFlags(new String[]{"ALL_FIELDS"});
  ObjectMapper objectMapper = new ObjectMapper();
  
  logger.info("calling XBrainTradeQuery and  Input:{}",objectMapper.writeValueAsString(request));
  
  HttpHeaders headers = new HttpHeaders();
  
  headers.setContentType(MediaType.APPLICATION_JSON);
  
   try
         {
         restTemplate = new RestTemplate();
  
         ResponseEntity&lt;XBrainTradeList&gt; result=null;
         xBrainTradeList =null;
  
         ResponseEntity&lt;XBrainTradeList&gt; result1 = restTemplate.exchange(XBrainTradeQueryURL, HttpMethod.POST, new HttpEntity(request, headers), XBrainTradeList.class);
  </code></pre>
  
  <p>and my XBrainQueryRequest class is as below</p>
  
  <pre><code>@JsonSerialize(include = JsonSerialize.Inclusion.NON_NULL)
  public class XBrainQueryRequest {
  
      private String queryId;
      private String[] flags;
      private String[] attributes;
  
      /**
       * @return the queryId
       */
  
      public String getQueryId() {
          return queryId;
      }
  
      public XBrainQueryRequest(String queryId, String[] flags, String[] attributes) {
          super();
          this.queryId = queryId;
          this.flags = flags;
          this.attributes = attributes;
      }
  
      public XBrainQueryRequest() {
      }
  
      public XBrainQueryRequest(String queryId, String[] flags) {
          super();
          this.queryId = queryId;
          this.flags = flags;
      }
  
      /**
       * @param queryId
       *            the queryId to set
       */
      public void setQueryId(String queryId) {
          this.queryId = queryId;
      }
  
      public String[] getFlags() {
          return flags;
      }
  
      public void setFlags(String[] flags) {
          this.flags = flags;
      }
  
      public String[] getAttributes() {
          return attributes;
      }
  
      public void setAttributes(String[] attributes) {
          this.attributes = attributes;
      }
  
  }
  </code></pre>
  
  <p>Can somebody explain me why I am getting error and how to solve it. I am new to these stuff.</p>