Todd Valentine
Todd Valentine

Reputation: 185

Silverstripe REST API

I am using Silverstripe Restfulserver and want to make a GET request to get a collection of data objects. For example, /events should return a list of events in some logical order. I see in the docs that you can make a POST call to /[dataobject] and create a new object and /[dataobject]/[id] to GET a specific object but is there not a GET alternative to return a collection? I currently have a events method created on the page controller to return the list, but was wondering if anyone had a more restful way to accomplish this in Silverstripe. Furthermore, is there a way to append params on to the route (/events?start=[date]&end=[date]) and GET a range of dates between the start and end params in a restful manner?

Upvotes: 0

Views: 1759

Answers (1)

gaethofs
gaethofs

Reputation: 21

In order to return a collection, you can just make a GET call to api/v1/[dataobject]/. If you have set the right canView() permissions on the DataObject, you will receive a list of all the DataObject entities of this type.

Upvotes: 2

Related Questions