---
post_title: 'Today I Learned #4: Passing array/list parameters to Phoenix controller'
author: dreat
layout: post
published: true
post_date: 2020-04-10 20:00:00
tags: [til, elixir, phoenix]
categories: [til, new_blog]
---

Hello!

I had curious _incident_ while working. I was to investigate why our API won't work when passed array as url parameter for GET request.

So, I peeked into the tests and we had test for it. I logged the incoming parameters and Phoenix got an array and worked with it perfectly. So I decided to grab the big guns. Enter curl.

It was quite funny. My first insting was to create url like this: 
```
some.url?param=[value1,value2]
```

but it didn't work. Phoenix read this as

```elixir
%{"param" => "[value1,value2]"}
```

and no combination of quotes would make this work.

To skip some other things I tried - the thing you need to do is to use this

```
some_url?param[]=value1&param[]=value2
```

Phoenix will read all those values as elements of an array (or, in Elixir's context, a list) and it will work as intended.
