title: ReastEasy Http Header for Client Request
body: <p>I'm accessing a rest web service using RestEasy ClienTRequest API. How can I set http header for the client request.</p>
  
  <p>I need to add the following name value pair as http header. </p>
  
  <pre><code>username   raj
  password   raj
  </code></pre>
  
  <p>This is the client code</p>
  
  <pre><code>public void getResponse(String uri, Defect defect)   {
  
           StringWriter writer = new StringWriter();
           try{
           JAXBContext jaxbContext = JAXBContext.newInstance(Defect.class);
           Marshaller jaxbMarshaller = jaxbContext.createMarshaller();
           jaxbMarshaller.marshal(defect, writer);
           }catch( JAXBException e){
  
           }
  
          //Define the API URI where API will be accessed
          ClientRequest request = new ClientRequest("https://dev.in/rest/service/create");
  
          //Set the accept header to tell the accepted response format
          request.body("application/xml", writer.getBuffer().toString());
         // request.header("raj", "raj");
          //Send the request
          ClientResponse response;
          try {
              response = request.post();
               int apiResponseCode = response.getResponseStatus().getStatusCode();
               if(response.getResponseStatus().getStatusCode() != 201)
                  {
                      throw new RuntimeException("Failed with HTTP error code : " + apiResponseCode);
                  }
               System.out.println("response "+response.toString());
          } catch (Exception e) {
              // TODO Auto-generated catch block
              e.printStackTrace();
          }
  
          //First validate the api status code
  
  
  
  
      }
  </code></pre>
  
  <p>Thanks in advance</p>
  
  <p>Tried this coxe. but not working</p>
  
  <pre><code>Map&lt;String, String&gt; headerParam = new HashMap&lt;String, String&gt;(); headerParam.put("username", "raj"); headerParam.put("password", "raj"); request.header(HttpHeaders.ACCEPT, headerParam);
  </code></pre>