elixirdev
Please help me to convert curl request to tesla post request
here is the curl request: curl -v POST 'URL_OF_API' \ -H 'Accept: application/json' \ -H 'Authorization: Bearer TOKEN' \ -F 'listing={"products": [{"row": "DD","seat": "13","name": "1-61c171f5-4a96-4c5e-bf2c-07e965b0f9cc.pdf"}]}; type=application/json' \ -F '1-61c171f5-4a96-4c5e-bf2c-07e965b0f9cc.pdf=@1-61c171f5-4a96-4c5e-bf2c-07e965b0f9cc.pdf;type=application/pdf'
how i am converting it.
body:
%Tesla.Multipart{
boundary: "983b569edcb39a5d0707fd9d00ad7931",
content_type_params: [],
parts: [
%Tesla.Multipart.Part{
body: "{\"products\":[{\"name\":\"1-61c171f5-4a96-4c5e-bf2c-07e965b0f9cc.pdf\",\"row\":\"DD\",\"seat\":\"13\"}]}",
dispositions: [name: "listing"],
headers: [{"content-type", "application/json"}]
},
%Tesla.Multipart.Part{
body: %File.Stream{
line_or_bytes: 2048,
modes: [:raw, :read_ahead, :read, :binary],
path: "priv/listing-files/listing-118755501/1-61c171f5-4a96-4c5e-bf2c-07e965b0f9cc.pdf",
raw: true
},
dispositions: [
name: "1-61c171f5-4a96-4c5e-bf2c-07e965b0f9cc.pdf",
filename: "1-61c171f5-4a96-4c5e-bf2c-07e965b0f9cc.pdf"
],
headers: [{"content-type", "application/pdf"}]
}
]
}
client:
%Tesla.Client{
adapter: nil,
fun: nil,
post: [],
pre: [
{Tesla.Middleware.BaseUrl, :call, ["BASE_URL"]},
{Tesla.Middleware.Headers, :call,
[
[
{"accept-language", "en-US"},
{"authorization", "Bearer TOKEN"}
]
]},
{Tesla.Middleware.JSON, :call, [[]]},
{Tesla.Middleware.Telemetry, :call, [[]]},
{Tesla.Middleware.Logger, :call, [[]]}
]
}
url: “/mobile/v3/1769384845”
opts: [adapter: [recv_timeout: 300000]]
Tesla.post(client, uri, body, opts: opts)
please tell me if I am missing something.
Most Liked
dimitarvp
Well, there’s this site: https://curl.trillworks.com/
…but it only converts to HTTPoison. Still, it might be a good start for you, then you can try to translate from it to Tesla?
4
Popular in Questions
Hello, I get Persian date from my client and convert it to normal calendar like this:
def jalali_string_to_miladi_english_number(persi...
New
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
As the title describes, I’m trying to run Enum.map() over a list of key/value pairs, where the value is a map. My data looks like this:
...
New
This should be a simple problem but I just can’t seem to figure it out. I have a standalone Elixir app that won’t find the database.
Dep...
New
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
As many of you may have realized by now (sorry for all the posts here) I’ve been working on a db problem where I’m trying to aggregate a ...
New
Could someone help me? I'm making my first elixir program, number guessing game. I can't figure out how to convert the user's guess from ...
New
Hey,
Just curious what are the main benefits of Elixir compared to Clojure?
When is Elixir more useful than Clojure and vice versa?
Th...
New
Given a string, how can I get access to its character by index? Enum.at("my_string", 2) doesn't work.
Or rather, not char, but a substr...
New
Hello again - after a longish gap I’ve decided I really must dig into Elixir and see what’s been happening here - so I have a few questio...
New
Other popular topics
Hi! May someone helps me, please!
I have two apps into an umbrella project: the first one is Database, which manages queries, and the se...
New
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
As the title describes, I’m trying to run Enum.map() over a list of key/value pairs, where the value is a map. My data looks like this:
...
New
We have an ECS cluster with 4 services, where each task joins a single cluster, via discovery ECS discovery service.
Currently when I de...
New
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...
New
I tried installing
elixir 1.11.2
erlang 23.3.4
via asdf in my zsh shell. Enabled the versions locally and globally.
When I list them ...
New
After calling mix ecto.create I get this error:
17:00:32.162 [error] GenServer #PID<0.412.0> terminating
** (Postgrex.Error) FATAL...
New
I am trying to run a deploy with docker and I successfully runned with this command:
docker build -t romenigld/blog-prod .
but when I t...
New
Why is it that the mnesia database isn’t the most preferred database for use in Elixir/Phoenix?
New
Hey :wave:t3: Elixir community,
I’ve been learning Elixir, and working on some side projects. My editor of choice is VSCode, and althoug...
New








