httpoison

How to get a video flow with Elixir/HTTPoison or Hackney?

本小妞迷上赌 提交于 2019-12-25 09:16:08
问题 I'm trying to get a stream from a cam using Elixir / HTTPoison and dump it into a file. Url is x.x.x.x/axis-cgi/mjpg/video.cgi?duration=1&resolution=320x240 Using the url in DHC (Chrome addon), i can have the following: Response 200 OK HEADERS Cache-Control: no-cache Pragma: no-cache Expires: Thu, 01 Dec 1994 16:00:00 GMT Connection: close Content-Type: multipart/x-mixed-replace; boundary=myboundary X-Time-Offset: 62044.312573 pretty COMPLETE REQUEST HEADERS Accept: / Accept-Encoding: gzip,

Use HTTPoison to initialize a module attribute

无人久伴 提交于 2019-12-24 01:46:08
问题 I am trying to do initialize a module attribute like this response = HTTPoison.get! url {:ok, response} = Poison.decode(response.body) @attr response I have done it before with a file, something like this: @external_resource file = Path.join([__DIR__, "file.txt"]) Module.register_attribute __MODULE__, :attr, accumulate: true for line <- File.stream!(file, [], :line) do @attr line ... Is not possible to do the same with HTTPoison and fetching the response of an API? I am receiving this error:

Phoenix/Elixir - cURL works, but HTTPoison fails

我的未来我决定 提交于 2019-12-11 15:25:56
问题 In my Phoenix app, I am trying to use the HTTPoison HTTP client (https://hexdocs.pm/httpoison/api-reference.html) to make a post request to the AgileCRM API. I was able to use cURL to make a successful request, but my attempt to replicate it in Phoenix is failing with a 401 UNAUTHORIZED error. My successful cURL: $ curl https://domain.agilecrm.com/dev/api/contacts/search/email \ -H "Accept: application/json" \ -d 'email_ids=["contact@test.com"]' \ -u admin@test.com:api_key which returns