Return an image from a REST call?

I managed to call a REST service which returns some JSON from a Javascript field.:partying_face:
But now I want to call another REST service which returns a PNG image:

The service is working fine; I can call it with CURL and it delivers an image I can save.

But calling it from the Javascript field doesn’t work so far. Why’s that?
The service is returning the image as raw bytes with “image/png” content type.
Can I improve the fetch() etc.?
Should it rather deliver base64 data which I then decode in Glide?

Yeah, I think Base64 is probably the way to go. Not sure if the decoded image will work in an image component, but worth a try.

I switched to returning base64 - but the image component won’t display the image. Bummer😕
What else could I do?

I want to avoid putting the images on GDrive or the like. I would have to deal with garbage collection. The images are only of temporary value.

My use case is something like drawing a chart: I want to take some rows from a table and render the data. But not as a bar chart or pie chart. Hence I have to roll my own renderer. (Using pipedream for that.) It can return the image as a byte array or base64. Or whatever Glide needs - once I know what that is.

Quickchart has been a great option to return different charts as images. You will find quite a few posts about them in the forum. Basically you create the url, and that url is treated like an image url.
No REST APIs involved.

As for your case, I’m actually a bit surprised that a Base64 image doesn’t work. I’m pretty sure Glide can handle SVG images, so I know it’s somewhat capable of displaying text based images.

Just for something to try, create a template column with html image tags and your base64 result as the image source. Then try to display the html using a rich text component. Just curious if your image gets rendered that way.


Ah, that’s interesting: I haven’t tried the service as just an image resource. I was focused on a REST service to be called with POST + JSON as the request payload. Ultimately that’s what I need, I guess. But out of curiosity I could check if using it with GET is making a difference.

Thx for the idea! is the way to go

1 Like

Thanks a lot! It’s a great idea for two reasons:

  1. Maybe quickchart can do the job for me with one of its chart times. Maybe it would be a compromise, but it would save me time.
  2. It’s simple, but I kinda didn’t think about it: even JSON can be passed as part of the URL. Switching from POST to GET could help me use my own service with an image component.
1 Like

Yes, this is working!

  • I can pass in JSON to my pipedream workflow returning an image as bytes.
  • I build the URL with the JSON with a template column and assign that as the image source.

The chart is just a proof of concept. I’ll use a different one in the app. But that requires an answer to a different question…

1 Like

You can also use the Construct URL column, which is actually a better option as it will automatically URLencode your parameter arguments where necessary.

Did you actually take a look at

Nothing wrong with your pipedream approach, but it does seem like a bit of wheel reinventing to me? :person_shrugging:

1 Like