spring-projects / spring-projects/spring-hateoas
how to send entitymodel in client-side?
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 1.1k
- Forks
- 476
- PR merge metrics
- No merged PRs in 30d
Description
Code
URI uri = URI.create(request.getRequestURL() + "/" + post.getId());
HttpHeaders headers = new HttpHeaders();
HttpEntity httpEntity = new HttpEntity(entityModel, headers);
var returnType = new ParameterizedTypeReference<EntityModel<Post>>() {};
RestTemplate restTemplate = new RestTemplate(Arrays.asList(new MappingJackson2HttpMessageConverter()));
restTemplate.setMessageConverters(Traverson.getDefaultMessageConverters(MediaTypes.HAL_JSON));
var result = restTemplate.exchange(uri, HttpMethod.PUT, httpEntity, returnType);
Error
org.springframework.web.client.RestClientException: No HttpMessageConverter for org.springframework.hateoas.EntityModel
at org.springframework.web.client.RestTemplate$HttpEntityRequestCallback.doWithRequest(RestTemplate.java:961) ~[spring-web-5.2.8.RELEASE.jar:5.2.8.RELEASE]
at org.springframework.web.client.RestTemplate.doExecute(RestTemplate.java:737) ~[spring-web-5.2.8.RELEASE.jar:5.2.8.RELEASE]
at org.springframework.web.client.RestTemplate.execute(RestTemplate.java:714) ~[spring-web-5.2.8.RELEASE.jar:5.2.8.RELEASE]
at org.springframework.web.client.RestTemplate.exchange(RestTemplate.java:632) ~[spring-web-5.2.8.RELEASE.jar:5.2.8.RELEASE]
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the RestTemplate.exchange call and the MappingJackson2HttpMessageConverter and Traverson.getDefaultMessageConverters setup shown in the report. Reproduce the No HttpMessageConverter exception using the EntityModel request body, then determine what configuration or supported request representation is expected. Done means the client can send the EntityModel without the reported RestClientException.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java, spring
- Domain
- api, backend
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100