alxvallejo

alxvallejo

Help with passing param list in hackney GET body

Hey all,

I’m trying to make a GET request while passing in body params. One param requires a list of strings. The API documentation states:

curl -s --user 'api:YOUR_API_KEY' -G \
   https://api.mailgun.net/v3/YOUR_DOMAIN_NAME/stats/total \
   -d event='accepted' \
   -d event='delivered' \
   -d event='failed' \
   -d duration='1m'

In Elixir, here is how I’m preparing the body:

    body =
      %{event: ["accepted"]}
      |> Plug.Conn.Query.encode

However the response I get is:

    ** (Bamboo.ApiError) There was a problem sending the email through the Mailgun API.

Here is the response:

"{\"message\":\"please provide at least one event: Missing mandatory parameter: event\"}\n"

Here are the params we sent:

"event[]=accepted"

Any ideas on what i’m doing wrong here?

Most Liked

sb8244

sb8244

Author of Real-Time Phoenix

Can you include the code that calls out to Mailgun? I see the query preparation, but not how that is actually being sent along. My initial guess is that maybe that part is not setup correctly.

Do you mean query params? GET requests technically can have a body, but I would put the chances of a service respecting it very low.

Where Next?

Popular in Questions Top

JeremM34
Hello, how can I check the Phoenix version ? Thanks !
New
lanycrost
Hi everyone! I need implement if…else if…else condition from my elixir code, and anymore of this control flow structures not work proper...
New
mcarvalho
What is the difference between System.get_env and Application.get_env? For example, what are best practices to use one versus another.
New
bsollish-terakeet
Credo is smart enough to check for (something like) this: assert length(the_list) == 0 with this response: Checking if an enum is empt...
New
jerry
Good day to you all. I have been struggling to get a query involving like and ilike to work. Can anyone assist me on this, please? pro...
New
albydarned
Hello all! I am typing this post from my new MacBook Pro with the M1 chip. I’m loving it so far, and will probably use it as my daily dr...
New
jason.o
In the code below, if the create action is not set to accept “extra_key” as an input, it errors out with a message shown above. Is there ...
New

Other popular topics Top

Qqwy
Update: How to use the Blogs & Podcasts section You can post links to your blog posts or podcasts either in one of the Official Blog...
3271 130286 1222
New
KronicDeth
Elixir plugin for JetBrain’s IntelliJ Platform (including Rubymine) This is a plugin that adds support for Elixir to JetBrains IntelliJ...
289 36654 110
New
jononomo
For some reason my phoenix channels are working for me in my local dev environment, but as soon as I deploy via Docker, I get a 403 error...
New
nsuchy
Hi. I’ve noticed that Windows Powershell has it’s own IEX command and you cannot access Elixir’s IEX due to the conflict. This isn’t a cr...
New
sergio
Kind of like when jquery came out, it was super necessary. Existing drag and drop libraries have a bunch of baggage to support old browse...
New
AstonJ
Posting this to see if we can make things easier for people to get into Neovim. If you use Neovim and have a favourite distro please let ...
New

We're in Beta

About us Mission Statement