I\'m using spring data (mongoDb) and I\'ve got my repository:
public interface StoriesRepository extends PagingAndSortingRepository {}
<
As "pathfinder" mentioned you can use exchange
method of RestTemplate
. However instead of passing ParameterizedTypeReference
you should pass ParameterizedTypeReference
. When you get the response you could retrieve the content - Collection
.
The code should look like this:
ResponseEntity> response = restTemplate.exchange(getLocalhost("/story"),
HttpMethod.GET, null, new ParameterizedTypeReference>() {});
PagedResources storiesResources = response.getBody();
Collection stories = storiesResources.getContent();
Apart from the content storiesResources
holds page metadata and links too.
A more step-by-step explanation is available here: https://stackoverflow.com/a/46847429/8805916