title: GET Request with Content-Type and Accept header with JAX-RS Jersey 2.2
body: <p>I try to access an open data web service which gives me traffic infos. Documentation says that requests have to be <code>GET</code> and need to contain <code>Accept: application/json</code> and <code>Content-Type: application/json</code>. I don't understand why they need the <code>Content-Type</code> but ok:</p>
  
  <p>I tried to retrieve data with just the <code>Accept:</code> Header but I'm always getting a <code>415 Unsupported Media Type</code>. Now I am currently trying it this way (but I'm not sure if I am really setting both headers correctly):</p>
  
  <pre><code>String entity = ClientBuilder.newClient().target(liveDataURI)
      .path(liveDataPath)
      .request(MediaType.APPLICATION_JSON)
      .accept(MediaType.APPLICATION_JSON)
      .get(String.class);
  </code></pre>
  
  <p>As you see I am using Jersey 2.2 and I'm still getting a <code>415 Unsupported Media Type</code>.</p>
  
  <p><strong>EDIT</strong></p>
  
  <p>So I got it to work but I don't understand why. Isn't <code>accept(MediaType.APPLICATION_JSON)</code> and <code>header("Content-type","application/json")</code> the same?</p>
  
  <pre><code>String responseEntity = ClientBuilder.newClient()
      .target(liveDataURI)
      .path(liveDataPath)
      .request(MediaType.APPLICATION_JSON)
      .header("Content-type", "application/json")
      .get(String.class);
  </code></pre>