Hi. I’m getting binary in json response body instead of a string. It’s probably because the response json is too big.
What can I do in this situation? Or is it a bug with httpoison?
Thanks
iex(17)> {:ok, %HTTPoison.Response{body: body, status_code: 200}} = HTTPoison.get "https://url"
{:ok,
%HTTPoison.Response{body: <<31, 139, 8, 0, 0, 0, 0, 0, 0, 3, 237, 125, 121,
111, 219, 88, 182, 231, 87, 81, 121, 254, 233, 6, 204, 72, 20, 181, 22, 30,
166, 224, 53, 222, 109, 121, 143, 31, 6, 198, 149, 68, 137, 52, 37, 94, 153,
164, ...>>,
headers: [{"Server", "nginx/1.11.4"},
{"Date", "Tue, 10 Oct 2017 23:35:36 GMT"},
{"Content-Type", "application/json; charset=utf-8"},
{"Transfer-Encoding", "chunked"}, {"Connection", "keep-alive"},
{"cache-control", "max-age=300"},
{"x-request-id", "7qcnn88qvaf12tuc2u88nkqoj5odk19v"},
{"Expires", "Tue, 10 Oct 2017 23:40:36 GMT"}, {"Content-Encoding", "gzip"},
{"Access-Control-Allow-Origin", "*"}],
request_url: "https://url",
status_code: 200}}
iex(18)> body
<<31, 139, 8, 0, 0, 0, 0, 0, 0, 3, 237, 125, 121, 111, 219, 88, 182, 231, 87,
81, 121, 254, 233, 6, 204, 72, 20, 181, 22, 30, 166, 224, 53, 222, 109, 121,
143, 31, 6, 198, 149, 68, 137, 52, 37, 94, 153, 164, 100, 83, ...>>
iex(19)> Poison.decode body
{:error, {:invalid, <<31>>, 0}}
iex(20)>