# POST a JSON array to a Controller

**URL:** <https://help.nextcloud.com/t/post-a-json-array-to-a-controller/15290>\
**Category:** 💻 Development\
**Tags:** app-development\
**Created:** [July 12, 2017, 7:31am UTC](https://help.nextcloud.com/t/post-a-json-array-to-a-controller/15290 "2017-07-12T07:31:56Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![korelstar](https://help.nextcloud.com/letter_avatar/korelstar/32/5_5575768a8748004e209b776fc1b2916d.png) [@korelstar](https://help.nextcloud.com/u/korelstar)\
**Post date:** [July 12, 2017, 7:31am UTC](https://help.nextcloud.com/t/post-a-json-array-to-a-controller/15290/1 "2017-07-12T07:31:56Z")

</div>

I would like to write a Controller to which a client can pass a JSON Array (e.g. using POST).

Example:

```auto
POST /index.php/apps/myapp/api
[{id:5,data:"xyz"},{id:8,data:"xyz"}]

```

Unfortunately, I found no way, how to access this array in the Controller, since there is no variable Name, I can use as Parameter in my Controller method.

Is this possible, or would I have to embed my Array in a JSON object?  
e.g.: `{items: [{id:5,data:"xyz"},{id:8,data:"xyz"}]}`

Then, I could use the variable `$items` as parameter in my Controller. However, the JSON string would be more complicated. Is there a better way?

---

<div class="post-metadata">

**Author:** ![BernhardPosselt](https://help.nextcloud.com/user_avatar/help.nextcloud.com/bernhardposselt/32/82_2.png) [@BernhardPosselt](https://help.nextcloud.com/u/BernhardPosselt)\
**Post date:** [July 12, 2017, 5:22pm UTC](https://help.nextcloud.com/t/post-a-json-array-to-a-controller/15290/2 "2017-07-12T17:22:10Z")

</div>

You can embed it in a JSON object like the one above and then just use $items as variable name in your method. Another way would be to simply use $this-\>request-\>params for the whole JSON object AFAIK.
