title: How to add Headers on RESTful call using Jersey Client API
body: <p>Here is the Format for RESTful call:</p>
  
  <pre><code>HEADERS:
      Content-Type: application/json;charset=UTF-8
      Authorization: Bearer Rc7JE8P7XUgSCPogjhdsVLMfITqQQrjg
  
  REQUEST:
      GET https://api.example.com/1/realTime?json={"selection":{"includeAlerts":"true","selectionType":"registered","selectionMatch":"","isTheEvent":"true","includeRuntime":"true"}}
  </code></pre>
  
  <p>Here is my codes:</p>
  
  <pre><code>                try
                  {
                   Client client = Client.create();
                   WebResource webResource = 
                           client.resource("https://api.example.com/1/realTime?json=
                           {"selection":{"includeAlerts":"true","selectionType":"registered","selectionMatch":"","isTheEvent":"true","includeRuntime":"true"}}");
  
                   //add header:Content-Type: application/json;charset=UTF-8
                   webResource.setProperty("Content-Type", "application/json;charset=UTF-8");
  
                   //add header: Authorization Bearer Rc7JE8P7XUgSCPogsdfdLMfITqQQrjg
                   value = "Bearer " + value;
                   webResource.setProperty("Authorization", value);
  
                   MultivaluedMap&lt;String, String&gt; queryParams = new MultivaluedMapImpl();
                   queryParams.add("json", js);
  
                   //Get response from RESTful Server
                   jsonStr = webResource.get(String.class);
                   System.out.println("Testing:");
                   System.out.println(jsonStr);
  
                  }
                  catch (Exception e)
                  {
                    System.out.println (e.getMessage());
                    e.printStackTrace();
                    System.exit(0);
                  }
  </code></pre>
  
  <p>But it returns error</p>
  
  <pre><code>com.sun.jersey.api.client.UniformInterfaceException: GET https://api.example.com/1/realTime? returned a response status of 500
      at com.sun.jersey.api.client.WebResource.handle(WebResource.java:607)
      at com.sun.jersey.api.client.WebResource.get(WebResource.java:187)
      at net.yorkland.restful.GetThermostatlist.GetThermostats(GetThermostatlist.java:60)
  </code></pre>
  
  <p>I think I didn't add headers correctly. </p>
  
  <p>Can someone help me to fix it? Please give me advice how to add headers on request.</p>
  
  <p>Thank you</p>