title: java.util.LinkedHashMap cannot be cast to java.lang.String (RestTemplate)
body: <p>Getting a Casting Exception on the Object returned from the API Call.  I am using Spring's RestTemplate to make the API Calls. I know the reason why but unsure about the best solution. The error is on the following line:</p>
  
  <p>The following fails with Exception:</p>
  
  <pre><code>Map map = restTemplate.postForObject(buildUri(yqlQuery),request, LinkedHashMap.class);
  </code></pre>
  
  <p>And this too:</p>
  
  <pre><code>Profile profile = restTemplate.postForObject(buildUri(yqlQuery),request, Profile.class);;
  </code></pre>
  
  <p>Exception</p>
  
  <pre><code>java.lang.ClassCastException: java.util.LinkedHashMap cannot be cast to java.lang.String
    org.springframework.social.yahoo.api.impl.YahooErrorHandler.handleClientErrors(YahooErrorHandler.java:50)
    org.springframework.social.yahoo.api.impl.YahooErrorHandler.handleError(YahooErrorHandler.java:33)
    org.springframework.web.client.RestTemplate.handleResponseError(RestTemplate.java:615)
    org.springframework.web.client.RestTemplate.doExecute(RestTemplate.java:573)
    org.springframework.web.client.RestTemplate.execute(RestTemplate.java:544)
    org.springframework.web.client.RestTemplate.postForObject(RestTemplate.java:347)
    org.springframework.social.yahoo.api.impl.ProfileTemplate.profile(ProfileTemplate.java:35)
    org.springframework.social.yahoo.connect.YahooAdapter.setConnectionValues(YahooAdapter.java:30)
    org.springframework.social.yahoo.connect.YahooAdapter.setConnectionValues(YahooAdapter.java:15)
    org.springframework.social.connect.support.AbstractConnection.setValues(AbstractConnection.java:174)
    org.springframework.social.connect.support.AbstractConnection.initKey(AbstractConnection.java:137)
    org.springframework.social.connect.support.OAuth1Connection.&lt;init&gt;(OAuth1Connection.java:59)
    org.springframework.social.connect.support.OAuth1ConnectionFactory.createConnection(OAuth1ConnectionFactory.java:59)
    org.springframework.social.security.provider.OAuth1AuthenticationService.getAuthToken(OAuth1AuthenticationService.java:112)
    org.springframework.social.security.SocialAuthenticationFilter.attemptAuthService(SocialAuthenticationFilter.java:239)
    org.springframework.social.security.SocialAuthenticationFilter.attemptAuthentication(SocialAuthenticationFilter.java:157)
    org.springframework.security.web.authentication.AbstractAuthenticationProcessingFilter.doFilter(AbstractAuthenticationProcessingFilter.java:211)
    org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
    org.springframework.security.web.authentication.logout.LogoutFilter.doFilter(LogoutFilter.java:110)
    org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
    org.springframework.security.web.csrf.CsrfFilter.doFilterInternal(CsrfFilter.java:85)
    org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
    org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
    org.springframework.security.web.header.HeaderWriterFilter.doFilterInternal(HeaderWriterFilter.java:57)
    org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
    org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
    org.springframework.security.web.context.SecurityContextPersistenceFilter.doFilter(SecurityContextPersistenceFilter.java:87)
    org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
    org.springframework.security.web.context.request.async.WebAsyncManagerIntegrationFilter.doFilterInternal(WebAsyncManagerIntegrationFilter.java:50)
    org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
    org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
    org.springframework.security.web.FilterChainProxy.doFilterInternal(FilterChainProxy.java:192)
    org.springframework.security.web.FilterChainProxy.doFilter(FilterChainProxy.java:160)
    org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:344)
    org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:261)
  </code></pre>
  
  <p>Class Excerpt</p>
  
  <pre><code>public class ProfileTemplate extends AbstractOperations implements ProOps {
          private final RestTemplate restTemplate;
          @Override
          public Profile profile() throws JsonParseException, JsonMappingException, IOException,UnsupportedEncodingException {
              MultiValueMap&lt;String, String&gt; request = new LinkedMultiValueMap&lt;String, String&gt;();
              request.set("format","json");
              String yqlQuery = UriUtils.encodePath("...", "UTF-8");
              Map map = restTemplate.postForObject(buildUri(yqlQuery),request, LinkedHashMap.class);
              Profile profile = objectMapper().convertValue(map.get("profile"), Profile.class);
              return profile;
          }
  </code></pre>
  
  <p>}</p>