Working with images & qr codes in Elixir Phoenix

I’m trying to get an QR code from the google API.

    url = "https://chart.googleapis.com/chart?chs=150x150&cht=qr&chl=Hello%20world"
    response = HTTPoison.get!(url)

How do I send the body of the response as json out in my Phoenix application?

Right now I’m getting the following error:

** (exit) an exception was raised:
    ** (Jason.EncodeError) invalid byte 0x89 in <<137, 80, 78, 71, 13, 10, 26, 10, 0, 0, 0, 13, 73, 72, 68, 82, 0, 0, 0, 150, 0, 0, 0, 150, 8, 2, 0, 0, 0, 179, 99, 230, 181, 0, 0, 0, 6, 98, 75, 71, 68, 0, 255, 0, 255, 0, 255, 160, 189, 167, ...>>

How do I solve this Issue?

I guess it’s gzipped…

UPDATE: No, it’s not. See next post :slight_smile:

:wave:

As https://chart.googleapis.com/chart?chs=150x150&cht=qr&chl=Hello%20world returns a QR code as an image, you’d need to decode the QR code first.

3 Likes