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
I am trying to figure out how Mix knows whether the environment is test, dev, or prod – where is this set?
Thanks.
New
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
How to bind a phoenix app to a specific ip address?
could not find anything about that, nowhere, unfortunately, but for me this is quite...
New
Is there a way to rollback a specific migration and only that one (“skipping” all the other ones)?
Would
mix ecto.rollback -v 200809061...
New
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
i’m a new one to elixir
which editor can i use
vs code? or atom?
Thanks! :smiley:
New
If I have a string “1000 cfu/ml” . I want to remove the characters and / and space . So the string is like this
"1000"
What is the ...
New
Hi,
I need to transform a list of numbers into a map where the keys are the indexes and the values are the original values of the list. ...
New
I would like to know what is the best IDE for elixir development?
New
Lets say I have map like this fetching from my database
%{"_id" => #BSON.ObjectId<58eb1a7a9ad169198c3dXXXX>, "email" => ...
New
Other popular topics
Hi, this is for people who, like me, have had some friction using .html.heex templates in VSCode.
The solution seems to be, in a hyphena...
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
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
Hello everybody,
usually, I use a 29" ultra-wide monitor for VSCode which can easily accomodate explorer (files panel) + file with code ...
New
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
Elixir plugin for JetBrain’s IntelliJ Platform (including Rubymine)
This is a plugin that adds support for Elixir to JetBrains IntelliJ...
New
What is the proper way to load a module from a file in to IEX?
In the python world, doing something like this pretty standard:
from ....
New
Seen any cool LiveView demos, sample apps or examples? Please post them here! :003:
New
For some reason my phoenix channels are working for me in my local dev environment, but as soon as I deploy via Docker, I get a 403 error...
New
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
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #deployment
- #library
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #channels
- #elixirconf
- #exunit
- #discussion
- #code-sync
- #javascript
- #podcasts
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ecto-query
- #elixir-ls
- #phoenix_html
- #iex
- #blog-post
- #graphql
- #genstage
- #ai
- #websockets
- #supervisor
- #advent-of-code
- #elixirconf-us
- #distillery
- #processes
- #forms
- #api
- #metaprogramming
- #security
- #performance








