{"action":"created","issue":{"url":"https://api.github.com/repos/spring-projects/spring-hateoas/issues/430","repository_url":"https://api.github.com/repos/spring-projects/spring-hateoas","labels_url":"https://api.github.com/repos/spring-projects/spring-hateoas/issues/430/labels{/name}","comments_url":"https://api.github.com/repos/spring-projects/spring-hateoas/issues/430/comments","events_url":"https://api.github.com/repos/spring-projects/spring-hateoas/issues/430/events","html_url":"https://github.com/spring-projects/spring-hateoas/issues/430","id":128890420,"number":430,"title":"RestTemplate configuration to deserialize HAL and also POST/PATCH back to server","user":{"login":"lennyk","id":4040241,"avatar_url":"https://avatars.githubusercontent.com/u/4040241?v=3","gravatar_id":"","url":"https://api.github.com/users/lennyk","html_url":"https://github.com/lennyk","followers_url":"https://api.github.com/users/lennyk/followers","following_url":"https://api.github.com/users/lennyk/following{/other_user}","gists_url":"https://api.github.com/users/lennyk/gists{/gist_id}","starred_url":"https://api.github.com/users/lennyk/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lennyk/subscriptions","organizations_url":"https://api.github.com/users/lennyk/orgs","repos_url":"https://api.github.com/users/lennyk/repos","events_url":"https://api.github.com/users/lennyk/events{/privacy}","received_events_url":"https://api.github.com/users/lennyk/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2016-01-26T17:42:33Z","updated_at":"2016-02-03T03:25:30Z","closed_at":null,"body":"We're having an issue with RestTemplate and HATEOAS on a project. We have a Spring REST client application that communicates with a SDR app. We can't get a RestTemplate configuration that can both serialize and deserialize our entities in the client.\r\n\r\nOur entities look like this (excerpt):\r\n\r\n```java\r\n@JsonIgnoreProperties(ignoreUnknown = true)\r\npublic class User extends ResourceSupport {\r\n    private String username;\r\n\r\n    public String getUsername() {\r\n        return username;\r\n    }\r\n\r\n    public void setUsername(String username) {\r\n        this.username = username;\r\n    }\r\n\r\n    @JsonSerialize(using = SelfLinkSerializer.class)\r\n    public Organization getOrganization() {\r\n        if (hasLink(\"organization\")) {\r\n            URI organization = UriComponentsBuilder.fromUriString(getLink(\"organization\").getHref()).build().toUri();\r\n            Traverson traverson = new Traverson(organization, MediaTypes.HAL_JSON);\r\n            return traverson.follow(\"self\").toObject(Organization.class);\r\n        }\r\n        return null;\r\n    }\r\n\r\n    public void setOrganization(Organization organization) {\r\n        if (hasLink(\"organization\")) {\r\n            getLinks().remove(getLink(\"organization\"));\r\n        }\r\n        Link organizationLink = new Link(organization.getLink(\"self\").getHref(), \"organization\");\r\n        add(organizationLink);\r\n    }\r\n}\r\n```\r\n\r\nOur RestTemplate that can deserialize responses from the server has Jackson2HalModule in the ObjectMapper:\r\n```java\r\n...\r\nObjectMapper objectMapper = new ObjectMapper();\r\nobjectMapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);\r\nobjectMapper.registerModule(new Jackson2HalModule());\r\n...\r\n```\r\n\r\nBut that RestTemplate can't serialize entities for PUT, PATCH etc. We have to take the Jackson2HalModule line out of the configuration. Then it can serialize the request but fails on deserializing the response. So we don't have a working solution using RestTemplate.\r\n\r\nWe've put together a sample application that demonstrates our problem:\r\nhttps://github.com/lennyk/resttemplate-spike-server (run the spring app)\r\nhttps://github.com/lennyk/resttemplate-spike (run the test with the server running)\r\n\r\nAny ideas?"},"comment":{"url":"https://api.github.com/repos/spring-projects/spring-hateoas/issues/comments/178980318","html_url":"https://github.com/spring-projects/spring-hateoas/issues/430#issuecomment-178980318","issue_url":"https://api.github.com/repos/spring-projects/spring-hateoas/issues/430","id":178980318,"user":{"login":"gregturn","id":311040,"avatar_url":"https://avatars.githubusercontent.com/u/311040?v=3","gravatar_id":"","url":"https://api.github.com/users/gregturn","html_url":"https://github.com/gregturn","followers_url":"https://api.github.com/users/gregturn/followers","following_url":"https://api.github.com/users/gregturn/following{/other_user}","gists_url":"https://api.github.com/users/gregturn/gists{/gist_id}","starred_url":"https://api.github.com/users/gregturn/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gregturn/subscriptions","organizations_url":"https://api.github.com/users/gregturn/orgs","repos_url":"https://api.github.com/users/gregturn/repos","events_url":"https://api.github.com/users/gregturn/events{/privacy}","received_events_url":"https://api.github.com/users/gregturn/received_events","type":"User","site_admin":false},"created_at":"2016-02-03T03:25:30Z","updated_at":"2016-02-03T03:25:30Z","body":"See my feedback at https://github.com/lennyk/resttemplate-spike/pull/1"}}