0

Sorry, I am using Phonenix Framwork / Elixir, I need use HTTPoison with a large json in PUT method, but always send a response error, What i can do ?

This is mi function code

def download(json, conn) do
 HTTPoison.start()
    "url"
    |> HTTPoison.post(json, [{"Content-Type", "application/json"}], recv_timeout: 800_000)
    |> case do
      {:ok, response} -> result = response.body
      {:ok, result}
      conn
      |> put_resp_content_type("application/pdf")
      |> put_resp_header("content-disposition", "attachment; filename=LB.pdf")
      |> Plug.Conn.send_resp(:ok, result)
    end
end
Adam Millerchip
  • 20,844
  • 5
  • 51
  • 74
Hunter
  • 1
  • 1
    Can you simplify this? You are doing 2 things here: making a post request and sending a pdf response. Does the post request work? (I don't see a put request). Does the download work if you save the result of the post and try sending that? – Everett Feb 23 '21 at 13:01
  • @Everett Yes this work it, but with json small or medium, and i am using this for create a pdf file with a service in remote server, the problem is with a json large... i newbie – Hunter Feb 23 '21 at 16:42
  • how large is large? If it is a size restriction causing the problem, perhaps gzip could help you. https://stackoverflow.com/questions/11414987/what-header-should-be-used-for-sending-gzip-compressed-json-from-android-client – David Bern Mar 05 '21 at 10:35

0 Answers0