How to consume an empty collection without a HAL response structure in spring -data-rest

I am using spring -data-rest in my application. I configured repositoryRest using configureRepositoryRestConfiguration

I added the following two lines in this configuration

config.exposeIdsFor(Person.class); config.setDefaultMediaType(MediaType.APPLICATION_JSON_UTF8); config.useHalAsDefaultJsonMediaType(false); 

Before adding this configuration, my answer is as follows

 { "_embedded": { "persons": [] }, "_links": { "self": { "href": "http://192.168.2.42:8082/persons/search/findByGroupId?groupId=44" } } } 

I can get a list of empty people using RestTemplate, as expected. But after adding the above configuration, I get the following response structure

 { "links": [{ "rel": "self", "href": "http://localhost:8082/persons/search/findByGroupId?groupId=44" }], "content": [{ "collectionValue": true, "relTargetType": "com.myapp.example.domain.Person", "value": [] }] } 

with this answer, RestTemplate returns a list of size 1 containing null values ​​for all attributes in my domain.

Can someone help get an empty list with this structure.

I used the following code to get a response from the API:

 restTemplate.exchange( url, GET, HttpEntity.EMPTY, parameterizedTypeReference<Resources<Person>>, Collections.emptyMap() ); 

UPDATE:

Is this a spring-data-rest error. Because somewhere in the code instead of Person , EmbeddedWrapper used as a domain type. After studying the code, I found that "collectionValue" , "relTargetType" and "value" in the JSON response are deserialized from the EmbeddedWrapper class.

Contact: EmbeddedWrappers.java

+7
spring-data-rest spring-hateoas spring-mvc spring-4
source share

No one has answered this question yet.

See related questions:

2480
How do I send JSON data using Curl from a terminal / command line in Test Spring REST?
84
POSTing combining @ OneToMany-sub-resources in Spring Data REST
7
Display collection object reference in spring REST data
4
How to use a list of subjects' responses from spring-rest data
one
Spring data source - invalid href resource
one
Spring Data REST returns EmptyCollectionEmbeddedWrapper instead of an empty collection
0
How to use Spring Data Rest API response with Retrofit 2 when communication is empty?
0
How to build a complex HATEOAS HAL json to send to rest as RequestBody
0
HAL Spring Hate REST Consumption
0
how to display JSON response using Spring-data-rest data with its object using RestTEmplate

All Articles