RESTful API forgotten URI options


(Damien) #1

Hi all,

It’s been some time since I’ve developed an API in Yii2 but I’m now trying to remember how to query or implement what I think is builtin options in an API but I can’t seem to find them now so I’m unsure.

Is there an option to query multiple records with the standard detail request like GET /users/1,2,3 to list these three users.

Also I kind of remember you could add related models in the URL that you want to include in the response. For example, if by default user.posts is not included in the user response, you could optionally include in the request like GET /users/1?with=posts.

Is this right? I’m trying it and searching Google but not finding them.


(Alexander Makarov) #2

There is no option to get multiple records via IDs yet. https://github.com/yiisoft/yii2/issues/4478

Related models are included via "expand", not via "with".


(Damien) #3

Excellent. I got it. Thanks for the reply.