Silverstripe REST API

耗尽温柔 提交于 2019-12-25 16:49:48

问题


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?


回答1:


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.



来源:https://stackoverflow.com/questions/20831602/silverstripe-rest-api

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!