Using Req, I’m making a GET request to microsoft’s graph API which it returns a result with the following header: "transfer-encoding" => ["chunked"]
, and a partial response.
After some looking around, I found this post: Handling http response streaming - #2 by garrison, which says I should be using the into:
option.
So my request now looks like this:
Req.get("https://graph.microsoft.com/v1.0/me/events?$expand=extensions",
headers: ...,
into: fn {:data, data}, {req, resp} ->
IO.inspect(data, label: "data")
resp = Req.Request.update_private(resp, :chunked_response, [data], &[data | &1])
{:cont, {req, resp}}
end
)
However, it seems it’s not continuing. The iteration only calls once, with a very partial bit of json
data: "{\"@odata.context\":\"https://graph.microsoft.com/v1.0/$metadata#users('xxxxxx')/events(extensions())\",\"value\":["
Im wondering if anyone more famaliar with Req can point out any blunder I might of made?
The full response from the Req.get
{:ok,
%Req.Response{
status: 200,
headers: %{
"cache-control" => ["private"],
"client-request-id" => ["xxxxxxxx"],
"content-type" => ["application/json; odata.metadata=minimal; odata.streaming=true; IEEE754Compatible=false; charset=utf-8"],
"date" => ["Tue, 10 Jun 2025 17:43:01 GMT"],
"request-id" => ["xxxxxxx"],
"strict-transport-security" => ["max-age=31536000"],
"transfer-encoding" => ["chunked"],
"x-ms-ags-diagnostic" => ["{\"ServerInfo\":{\"DataCenter\":\"UK South\",\"Slice\":\"E\",\"Ring\":\"5\",\"ScaleUnit\":\"006\",\"RoleInstance\":\"LN2PEPF00013DFE\"}}"]
},
body: "",
trailers: %{},
private: %{
chunked_response: ["{\"@odata.context\":\"https://graph.microsoft.com/v1.0/$metadata#users('xxxxxx')/events(extensions())\",\"value\":["]
}
}}
(I’ve swapped out any ID’s for xxxxxx)