nekperu15739
nekperu15739

Reputation: 3708

How call findAllById defined on Spring Data Rest?

I want to use the method findAllById that comes with spring-data, and its supose to be public by spring-data-rest. However i'm not able to make the correct request to call this method, there is no sample on documentation.

i trying something like this:

http://{{host}}:{{port}}/data/?id=1,2,3

but it's not working, any ideas?

Source: https://github.com/nekperu15739/dataSource-WS-REST

Upvotes: 0

Views: 815

Answers (2)

Amnon
Amnon

Reputation: 2320

The method findAllById from your Repository super interfaces is not exported as a REST search resource when using @RepositoryRestResource. You could instead add a method to your FooRepository interface to ahieve the same behaviour:

    List<Foo> findByIdIn(List<String> ids);

It will be exposed as /foo/search/findByIdIn{?ids}

Upvotes: 0

Alan Hay
Alan Hay

Reputation: 23246

That method comes with Spring Data but I am not sure if it is, by default, exported as a Rest endpoint.

If it is then it would be under the search path:

e.g. http://{{host}}:{{port}}/customers/search/findAllById?id=1,2,3

If it isn't then consider overriding and explicitly exporting.

@RestResource(exported = true)
Iterable<Customer> findAllById(...)

Upvotes: 1

Related Questions