Recently, I’ve went ahead and updated all dependencies (cowboy mainly) and Elixir… Everything is working great except this extremely weird issue with HTTPoison
requests. I want to hit a webhook on another Phoenix server, so I do:
HTTPoison.post(
@webhooks_uri <> path,
Poison.encode!(params),
[{"Content-Type", "application/json"}],
[ssl: [{:versions, [:'tlsv1.2']}]]
)
I am getting a response 400 Internal Server Error
. Debug logs from the receiving server is showing that the params are empty, even though I’m sending the account uid.
Testing through postman, the receiving server is getting the request just fine! So, I tried to hit httpbin.org/post through the HTTPoison code, and got this:
%HTTPoison.Response{body: body,
headers: [{"Server", "nginx"}, {"Date", "Wed, 15 Mar 2017 18:36:58 GMT"},
{"Content-Type", "application/json"}, {"Content-Length", "436"},
{"Connection", "keep-alive"}, {"Access-Control-Allow-Origin", "*"},
{"Access-Control-Allow-Credentials", "true"}], status_code: 200}}
# decoded body for readability:
%{"args" => %{},
"data" => "{\"account_uid\": \"91c43585-a38d-4edf-ad25-9da62fc9aecd\"}",
"files" => %{}, "form" => %{},
"headers" => %{"Content-Length" => "55",
"Content-Type" => "application/json, application/json",
"Host" => "httpbin.org", "User-Agent" => "hackney/1.6.6"},
"json" => %{"account_uid" => "91c43585-a38d-4edf-ad25-9da62fc9aecd"},
"origin" => "94.202.255.10", "url" => "http://httpbin.org/post"}
Nothing seems out of place … Where should I look next? tcpdump?