title: Why RestTemplate drops links from HAL+JSON response?
body: <p>I am using RestTemplate for testing APIs exposed through Spring DATA REST and I cannot get links when parsing the response. The rest template is configured with Jackson2HalModule backed HttpConverter, and Entity requested has links to associations that appear in the JSON response alright.</p>
  
  <p>Here's the JSON</p>
  
  <pre><code>{
    "name" : "Hero @ Bangalore",
    "venue" : {
      "name" : "Wayne Manor",
      "address" : "1 MG Road",
      "city" : "Bangalore",
      "state" : "Karnataka",
      "pincode" : "560001"
    },
    "seatsAvailable" : 40,
    "workshopType" : "Batman Challengers",
    "date" : "2015-09-10",
    "_links" : {
      "self" : {
        "href" : "http://localhost:8080/workshops/1{?projection}",
        "templated" : true
      },
      "venue" : {
        "href" : "http://localhost:8080/workshops/1/venue"
      }
    }
  }
  </code></pre>
  
  <p>The RestTemplate is configured as <a href="https://stackoverflow.com/questions/23239052/why-does-resttemplate-not-bind-response-representation-to-pagedresources">adviced in this post</a>, since we are getting a HAL+JSON response</p>
  
  <pre><code>ObjectMapper objectMapper = new ObjectMapper();
  objectMapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
  objectMapper.registerModule(new Jackson2HalModule());
  MappingJackson2HttpMessageConverter halConverter = new MappingJackson2HttpMessageConverter();
  halConverter.setSupportedMediaTypes(Arrays.asList(MediaTypes.HAL_JSON));
  halConverter.setObjectMapper(objectMapper);
  
  restTemplate = new RestTemplate();
  List&lt;HttpMessageConverter&lt;?&gt;&gt; existingConverters = restTemplate.getMessageConverters();
  List&lt;HttpMessageConverter&lt;?&gt;&gt; httpMessageConverters = new ArrayList&lt;&gt;();
  httpMessageConverters.add(halMessageConverter);
  httpMessageConverters.addAll(existingConverters);
  </code></pre>
  
  <p>Now, I expect links to be available in the parsed response object too, but that's not the case, here is how I fetch the response</p>
  
  <pre><code>ResponseEntity&lt;Resource&lt;Workshop&gt;&gt; workshopResource = 
  restTemplate
          .exchange(DEFAULT_PROJECTION, HttpMethod.GET, null,
              new ParameterizedTypeReference&lt;Resource&lt;Workshop&gt;&gt;() {
              });
  
  Workshop responseBody = workshopResource.getBody().getContent();
  </code></pre>
  
  <p>but then the assertion for venue link fails</p>
  
  <pre><code>assertTrue(workshopResource.getBody().getLink("venue").equals(paulURI.toString()));  
  </code></pre>
  
  <p>gives a <code>NullPointerException</code></p>