Fl4m3Ph03n1x

Fl4m3Ph03n1x

Is this the correct way of doing a post in HTTPoison?

Background

I have a POST request that I do using CURL the following way:

curl --data “reqCode=validateOfficeDetails&currLanguage=ca_ES” -X POST Generalitat de Catalunya - Oficina virtual de tràmits ciutadans

My objective is to replicate this request using HTTPoison.

Code

Thus far, this is how I am doing it:

HTTPoison.post("https://ovt.gencat.cat/gsitfc/AppJava/citpre/citpre.do", "reqCode=validateOfficeDetails&currLanguage=ca_ES", [{"Content-Type", "application/x-www-form-urlencoded"}])

But I am unsure this is the way to go because I am placing the --data parameters in what is the body.
Is this correct?

Marked As Solved

lucaong

lucaong

POST data is sent in the request body, so I’d say yes :slight_smile:

You are correctly setting the Content-Type to form urlencoded, matching your data.

We are so used to HTTP abstractions that it’s easy to forget how HTTP is really just text: request method, headers and body, it’s that simple :wink:

Also Liked

OvermindDL1

OvermindDL1

I would say yes? Is it not working?

Where Next?

Popular in Questions Top

baxterw3b
Hi guys, i’m new in the Elixir world, and i have to say, that i love it! i’m having some problem to understand anonymous functions with ...
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
skosch
To my knowledge, put_in, Map.update etc. all have the one limitation of not automatically creating intermediate keys when needed (for exa...
New
chrisalley
ExUnit now has describe blocks which is a welcome addition coming from RSpec. In the docs, it states that nested hierarchies of describe ...
New
pmjoe
I have a relationship of love and hate with Elixir. Lots of things are just absolutely right, but there are some things that are kind of ...
New
jay1
Why is it that the mnesia database isn’t the most preferred database for use in Elixir/Phoenix?
New
lucidguppy
I have a super simple question about elixir - how would I take a file like this foo bar baz and output a new file that enumerates th...
New
sergio_101
I am VERY much an elixir newbie. I have taken one elixir course and one phoenix course on Udemy. During that course, I saw the instructor...
New
joaquinalcerro
Hi there, I am working with Ecto-Postgresql and I need to call all of the records from a specific table but the table has 40,000 records...
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

Other popular topics Top

danschultzer
None of the current solutions worked well for me, so I went ahead and built a user management system from scratch. This project took far...
548 29603 241
New
New
lessless
I believe there are people here who are dealing with CSV files import on the daily basis, and since Excel is a really popular tool there ...
New
minhajuddin
I have seen a lot of code which picks the first element from a list using Enum.at(0) instead of List.first. Is there a reason why people ...
New
johnnyicon
Hi all, I’ve just started learning Elixir and Phoenix Framework, so please pardon my n00bness at this stage. I’m trying to use Postgres...
New
stefanchrobot
What’s the safe way to decode a JSON string into a struct? I want to avoid calling String.to_atom. Jason.decode can give me a map with st...
New
dblack
I’ve got an issue with an app and I’ve no idea of how to troubleshoot it. I’m hoping someone here might have seen something similar. I p...
New
boundedvariable
I am going through the kafka architecture. All the features what the kafka is providing are already in Erlang. I would like hear your opi...
New
AstonJ
Seen any cool LiveView demos, sample apps or examples? Please post them here! :003:
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

Latest on Elixir Forum

Elixir Forum

We're in Beta

About us Mission Statement