Srene

Srene

HTTPosion request format

Hi…
I have the following in python:

response = requests.post(url,data=parameters, auth=(api_key, ‘’))

What is the HTTPoison ot HTTPotion equivalent for this.
Thanks.

Most Liked

NobbZ

NobbZ

Please do not assume that anyone does know what a certain snippet in a foreign language does. Please try to explain how the request should look like.

collegeimprovements

collegeimprovements

HTTPoison is cool but take a look at Tesla also.

Link: https://github.com/teamon/tesla
Documentation: https://hexdocs.pm/tesla/api-reference.html

markkauffman2000

markkauffman2000

HTTPoison POST Example. Auth goes into the trailing options.
post!(url, body, headers \\ [], options \\ [])

iex(7)> {code, response} = HTTPoison.post "https://bd-partner-a-system.blackboard.com/learn/api/public/v1/oauth2/token", "grant_type=client_credentials", [{"Content-Type",  "application/x-www-form-urlencoded"}], [hackney: [basic_auth: {"user", "password"}] ]

The code is :ok, or not. The response will be an %HTTPoison.Response

HTTPotion POST Example. Most everything, including auth, goes into options.
response = HTTPotion.post(url, options \\ [])

iex(2)> options =  [body: "grant_type=client_credentials",
     headers: ["Content-Type": "application/x-www-form-urlencoded"],
     basic_auth: {"user","password"}]
iex(3)>response = HTTPotion.post("https://bd-partner-a-system.blackboard.com", options)

The response will be an %HTTPotion.Response.

Docs are easily found with a search. Between the docs you find and the above examples, you should be set!

Where Next?

Popular in Questions Top

tduccuong
Hi, is there any work on GUI with Elixir, that is similar to Electron/Javascript? My idea is to bundle Phoenix and BEAM into a single se...
New
aadeshere1
I have a another noob question about loop. Since elixir is immutable, while loop is not directly possible. total = 10 while total != 0 ...
New
chokchit
** (DBConnection.ConnectionError) connection not available and request was dropped from queue after 2733ms. You can configure how long re...
New
sen
Hi All, I set a environment variables in dev.exs , like below code. when i start server, how can i set the ${enable} value? thanks. d...
New
JorisKok
I have a server on AWS, and was running a load test using artillery. When looking at the Phoenix dashboard I see the Ports going to 100% ...
New
belgoros
I’m not a pro in using Regex and can’t figure out why the following behaviour happens, especially if we take into account the difference ...
New
RisingFromAshes
I've read in another post that it may be possible with a router helper - but I couldn't find an appropriate one, and tbh, I'm still just ...
New
ycv005
I have followed this StackOverflow post to install the specific version of Erlang. And When I am running mix ecto.setup then getting fol...
New
chensan
I have a User schema with a :from_id field set to type :string: defmodule TweetBot.Repo.Migrations.CreateUsers do use Ecto.Migration ...
New
hariharasudhan94
I would like to know what is the best IDE for elixir development?
New

Other popular topics Top

JorisKok
I have a server on AWS, and was running a load test using artillery. When looking at the Phoenix dashboard I see the Ports going to 100% ...
New
josevalim
Hi everyone, One of the features added to Elixir early on to help integration with Erlang code was the idea of overridable function defi...
New
ovidiubadita
Hey all, I discovered Elixir and I love it. I always wanted to learn a functional programming and I intended to go for Haskell, but afte...
New
nobody
Hi! In PHP: $SERVER['SERVERADDR'] - in Elixir? Searched the docs for ip address and the web, no good results. Thanks!
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
Please see the new poll here: Which code editor or IDE do you use? (Poll) (2022 Edition) It’s been a while since we first asked this, I...
208 31107 143
New
AstonJ
We’ve put together this wiki for Phoenix LiveView - please feel free to add any info you feel is worth including. What is Phoenix LiveV...
New
axelson
This post is a wiki (feel free to hit the edit button near the bottom right of this post to add your own changes!) This post collects co...
239 47849 226
New
svb
Hi! Currently I want to submit a form by pressing the Enter key. However, since my input field is of type “textarea” this is just adds a...
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

We're in Beta

About us Mission Statement