title: Spring for Android. MediaType throws IllegalArgumentException: Invalid token character ';' in token "json;charset=utf-8"
body: <p>I'm trying to use Spring for Android together with Jackson 2 to create a POJO from a rest call.</p>
  
  <pre><code>// Set the Accept header
  HttpHeaders requestHeaders = new HttpHeaders();
  requestHeaders.setAccept(Collections.singletonList(new MediaType("application","vnd.livescore_app.api.v1+json")));
  requestHeaders.setContentType(new MediaType("application","json;charset=utf-8"));
  HttpEntity&lt;?&gt; requestEntity = new HttpEntity&lt;Object&gt;(requestHeaders);
  
  // Create a new RestTemplate instance
  RestTemplate restTemplate = new RestTemplate();
  
  // Add the Jackson message converter
  restTemplate.getMessageConverters().add( new MappingJackson2HttpMessageConverter());
  
  // Make the HTTP GET request, marshaling the response from JSON to an array of Events
  ResponseEntity&lt;AppVersionObject&gt; responseEntity = restTemplate.exchange("https://example.com", HttpMethod.GET, requestEntity, AppVersionObject.class);
  AppVersionObject object = responseEntity.getBody();
  </code></pre>
  
  <p>Crashes with the following log trace</p>
  
  <pre><code>05-13 10:55:42.656: E/AndroidRuntime(19401): FATAL EXCEPTION: Thread-1470
  05-13 10:55:42.656: E/AndroidRuntime(19401): java.lang.IllegalArgumentException:Invalid token character ';' in token "json;charset=utf-8"
  05-13 10:55:42.656: E/AndroidRuntime(19401):    at org.springframework.http.MediaType.checkToken(MediaType.java:377)
  05-13 10:55:42.656: E/AndroidRuntime(19401):    at org.springframework.http.MediaType.&lt;init&gt;(MediaType.java:351)
  05-13 10:55:42.656: E/AndroidRuntime(19401):    at org.springframework.http.MediaType.&lt;init&gt;(MediaType.java:303)
  05-13 10:55:42.656: E/AndroidRuntime(19401):    at com.madinsweden.livescoretennis.service.CheckAppVersionTask.run(CheckAppVersionTask.java:41)
  05-13 10:55:42.656: E/AndroidRuntime(19401):    at java.lang.Thread.run(Thread.java:856)
  </code></pre>
  
  <p>I may of course change the content type to the more standardized <code>application/json</code> but then I get the following error.</p>
  
  <pre><code>05-13 11:03:07.054: E/AndroidRuntime(20010): org.springframework.web.client.RestClientException: Could not extract response: no suitable HttpMessageConverter found for response type [com.madinsweden.livescoretennis.backend.AppVersionObject] and content type [application/vnd.livescore_app.api.v1+json;charset=utf-8]
  05-13 11:03:07.054: E/AndroidRuntime(20010):    at org.springframework.web.client.HttpMessageConverterExtractor.extractData(HttpMessageConverterExtractor.java:79)
  05-13 11:03:07.054: E/AndroidRuntime(20010):    at org.springframework.web.client.RestTemplate$ResponseEntityResponseExtractor.extractData(RestTemplate.java:655)
  05-13 11:03:07.054: E/AndroidRuntime(20010):    at org.springframework.web.client.RestTemplate$ResponseEntityResponseExtractor.extractData(Rest Template.java:641)
  05-13 11:03:07.054: E/AndroidRuntime(20010):    at org.springframework.web.client.RestTemplate.doExecute(RestTemplate.java:484)
  05-13 11:03:07.054: E/AndroidRuntime(20010):    at org.springframework.web.client.RestTemplate.execute(RestTemplate.java:439)
  05-13 11:03:07.054: E/AndroidRuntime(20010):    at org.springframework.web.client.RestTemplate.exchange(RestTemplate.java:415)
  05-13 11:03:07.054: E/AndroidRuntime(20010):    at com.madinsweden.livescoretennis.service.CheckAppVersionTask.run(CheckAppVersionTask.java:51)
  05-13 11:03:07.054: E/AndroidRuntime(20010):    at java.lang.Thread.run(Thread.java:856)
  </code></pre>