BoZhenka
Hello there,
Here I have this request in curl:
curl
-H "AUTHENTICATION: HMAC GPLDIS8H7N5KY8DG:c6881c8bbcee2daceb5d8c2bb54078702bca23d828d7468afeb2f6ed0f25366f:1549890568"
-X GET
-d '{"customer_id":"Chrome","customer_ip":"127.0.0.1"}' 'https://testrest.vload.expert/voucher/validate/2698937783822253/Chrome/11234576536'
This is bad practice with using body in GET-request, unfortunately it is not my choice. So, how can I send it using some Elixir/Erlang library?
I was trying do it by using HTTPoison, HTTPotion in Elixir. And httpc in erlang, but httpc even don’t send GET-request if I put body to it:
:httpc.request(:get, {url, headers, 'text/plain', 'body'}, [], [])
Trending in Questions
I having some trouble figuring out if I have set myself too strict of standards for my production server. Currently I can handle 75% of r...
New
Documentation
While reading the Scoped Routes section, I noticed that the documentation currently refers to a problem without explainin...
New
Hello,
I’m trying to build a basic Phoenix web-app, and I’d like to use Tailwind.
However, when I launch mix phx.server, I get an error...
New
Hi everyone,
I am toying with the idea of building a “match maker” for giving personal help to people that wants to start coding.
I sta...
New
I recently noticed that Elixir’s Logger defaults its primary log level to :debug when no :logger, :level application configuration is pre...
New
I’m working on a small exercise involving update_in/3, and I came up with this solution:
data = %{
name: "Periodic Table",
category:...
New
I’ve got trouble wrapping my head around the order in which functions are called in this snippet (from Phoenix’s authentication):
toke...
New
Other Trending Topics
Edit: 2026 May 15 - This post is archived.
Mob is alive!!
Main docs: mob v0.7.11 — Documentation
A bit of explanation for the slightly c...
New
Hey, I’m Jesse and I’m the main contributor behind Dexter, a full-featured, lightning-fast Elixir LSP optimized for large codebases. It s...
New
I am happy to introduce the very α version of the new programming language compiled to BEAM.
Welcome Cure.
It has literally three kille...
New
Hobbes is a low-level distributed database for the Elixir programming language.
Hobbes provides a simple, safe, and scalable storage lay...
New
Hi everyone!
The first release candidate for the Expert language server project is now available!
We’ve published a press release detai...
New
A little off-topic, but I feel like people here have a good head on their shoulders.
I used to be quite good at making software. Was luc...
New
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #library
- #deployment
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #elixirconf
- #channels
- #exunit
- #discussion
- #code-sync
- #podcasts
- #javascript
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ai
- #ecto-query
- #elixirconf-us
- #blog-post
- #elixir-ls
- #phoenix_html
- #iex
- #graphql
- #genstage
- #websockets
- #supervisor
- #advent-of-code
- #distillery
- #processes
- #elixirconf-eu
- #api
- #forms
- #metaprogramming
- #hex










Showing Posts 1 to 10- Show Best Posts
- Show All (oldest first)
- Show All (newest first)
NobbZ
Not only bad style, but also absolutely useless, as it is not allowed to change the servers response.
Because of this proxies might decide to not forward the body.
And you away,
:httpcwouldn’t even send aGETrequest. Could you tell us what it does instead? Does it crash? Returns an error? Sends aPOST?BoZhenka
If change method to the POST, it will send. But it is not will be working because of someone wrote API only for a body with GET.
NobbZ
It htrows an error, Okay.
So
:httpcdoesn’t allow sending a body withGETrequest, you can not change that. (well you could “fork”:httpcand allow it, with a very high chance its just adding/removing some condition to a guard).Have you tried
HTTPotion.request? I consider the code ugly, and only skimmed it, but on a first glance I haven’t seen any guards against it. If though:hackneydoes validate the request you are out of luck again. Then you need to check the same forHTTPoisonand:ibrowse.And of course you can use
:tesla, it uses:httpc,:hackneyor:ibrowseas backend though.Last but not least, you can of course just omit the body, as its presence or content shouldn’t have any effect on the response, if though it does please point the authors of the API to the RFC:
And
GETdoes not define any semantics.Last but not least, you have the choice to simply use
System.cmdtocurlany request you want until you find a way to convince the API-Designer to repair their product…sribe
“Not allowed to” meet “real world”, “real world” meet “not allowed to”
I agree, obviously, that it is a HORRIBLE design for an API, in fact it is just not HTTP. And I would definitely point that out to the API designers, especially the part about proxies dropping it.
But ultimately, sometimes, we have to use non-compliant APIs.
lyo5ha
As far as HTTPoison builds on
.
hackney, it’s possible to handle such unconventional request. It’s not documented well on HTTPoison page, but worksNobbZ
BTDT, but even worse… The underlying server expected some headers in exact order, no more, no less…
Still, we were able to convince the API provider to change this behaviour, as we consumed the API via mobile networks which again were force proxies and the proxies of course touched the headers.
So telling the provider about problems might help them to see issues they didn’t know to exist.
sribe
Oh absolutely, I had to deal with one with case-sensitive headers, which presents some issues with Elixir. (Tests, IIRC, check case and want all lower…)
Funny thing is, we owned the service in question, and were afraid to even try to touch the code. In fact, that’s one extremely minor example of why the Elixir program in question came into existence.
But yeah, just to reiterate: do point it out to the devs, they may well want to fix it.
khaskelberg
This RFC is now obsolete. It was replaced by RFC 7230-7237. And this RFC allows to send body with GET request.
It is still not a good idea, but it doesn’t contradict HTTP/1.1 spec
NobbZ
I should take a closer look at those obseletion markers at the top
Neither does the fact that some clients do not allow to create such a request.
Anyway, there are clients available in elixir that allow
GETwith body as pointed out earlier. It’s not necessarily convenient to do soAnd still, third party issues exist. A proxy dropping the request does not act against the spec either and still makes it impossible to use the service. This is something that could cost the API provider money and they should be made aware of the issue.
BoZhenka
Blimey, how I missed it(
Thank’s