daveaztig14
How to use curl as input in elixir script?
Hi,
I am totally new in phoenix, elixir, and ecto. I have been studying for a week about basics and all, so far I’m quite amazed and confused at the same time. Anyway, my problem is this, I have a curl request which is:
curl https://sample.com/environment
-H ‘Content-Type: application/json; charset=utf-8’
-d ‘{“ticket”: 1, “ver”: “0.0.1.0_env”, “os”: “android”}’
I want to use the values of the variables “ticket”, “ver” and “os” as an input in my elixir/ecto script which will query in a remote database. (values is changing each request)
I’m sorry for my question if its a little confusing. Please feel free to ask questions so that I can clarify things. And also I want to know it it truly possible.
Any suggestions, help, links and ideas are welcome. I want to eagerly learn this. Thank you.
Most Liked
Qqwy
While it is possible to use curl from Elixir directly, it seems like what you actually want to do, is to perform a remote HTTP request and read the results.
Instead of manually using curl, I suggest using a HTTP client library such as HTTPoison, which does much of the request/response parsing and error handling for you.
NobbZ
daveaztig14
I am so sorry for my late response. Just an update:
Based on the research I’ve made and the ideas and suggestions you’ve given me, I now have a simple elixir app where in it accepts a request like:
curl “http://localhost:8085/pass” -H Content-Type: application/json; charset=utf-8’ -d ‘{“ticket”: 1, “ver”: “1”, “os”: “1”}’
and the output is:
ticket: 1, ver: 0.0.1.0_develop, os: ios
SQL Query = select * from database where ticket= 1 AND ver= 1 AND os= 1
Thank you for all your help, ideas and suggestions. together with this link https://www.jungledisk.com/blog/2018/03/19/tutorial-a-simple-http-server-in-elixir/.
It really helped me alot.
My next step now is to connect to a database and query the statement using elixir/ecto. However, it is another topic.
Once again. Thank you.
Popular in Questions
Other popular topics
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








