cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
ericonline
Community Champion
Community Champion

Convert API Response to .png

Hello,


Scenario:

  • HTTP Action
    • Calls Azure Maps Get Map Image API
    • Works great in Postman and browser. I can see the .png image.
  • I want to do various things with the response (insert .png into email body, save to sharepoint, save to sql, etc.)

Issue:

  • How do I convert the response to an actual .png image in Flow? 

Tried so far:

  • Parse JSON
    • Schema:
    • {
          "type": "object",
          "properties": {
              "$content-type": {
                  "type": "string"
              },
              "$content": {
                  "type": "string" //also tried "image/png" here, same result
              }
          }
      }
    • Results: Fail
    • image.png
  • OneDrive for Business: Create File
    • Result: This creates a .png file, BUT I don't want to create a file then delete a file in OneDrive. 
    • There has to be an Expression or something for this type of thing. 

Any ideas?


Thank you!

4 REPLIES 4
RezaDorrani
Dual Super User II
Dual Super User II

Hi @ericonline 

 

Try the followign expression for posting to SharePoint example -

Create file action

 

file name - map.jpeg

file content use the following expression - base64ToBinary( body('HTTP')?['$content'])

 

Regards,

Reza Dorrani

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly

yashag2255
Dual Super User II
Dual Super User II

Hi @ericonline 

 

So when you invoke the api with the http action, in the browser and in Postman, it shows you an image. In flow, that is not supported right now. You cannot see the image (you just get the binary content of that image). 

 

Can you share details on what you intend to do with this image in the consecutive steps? 

 

You can directly send it as email or store it somewhere too. 

 

Hope this Helps!

If this reply has answered your question or solved your issue, please mark this question as answered. Answered questions helps users in the future who may have the same issue or question quickly find a resolution via search. If you liked my response, please consider giving it a thumbs up. THANKS!

Hi @RezaDorrani  and @yashag2255

Ideally, I'd like to store the image as a variable then do anything I want with it, but I can't find a way to do that. 

So far, the following has worked:

- Create a file in OneDrive (Use OneDrive Create File Action)

- Create a file in Sharepoint (Use Sharepoint Create File Action + base64tobinary() expression, thanks @RezaDorrani )

- Add as an attachment to an email (attachment name: "test.png", content: body of API response)

Need assistance with:

- Add .png into the body of an HTML email

- Add .png into a COLUMN in a Sharepoint List

Got recipes for these?

@ericonline 

 

I do not beleive the email clients allow posting base64 encoded images into the body of the email

I tried posting it in html body but the email client strips out the imag src 

The image can be sent as an attachment to the email same as the way we did for SharePoint

 

Add .png into a column in SharePoint? What type of column is this? A multi line text - then just directly post the content into it (it will save the data in base64 format) and you can read it back in flow to generate the image

 

Regards,

Reza Dorrani

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly

Helpful resources

Announcements
UG GA Amplification 768x460.png

Launching new user group features

Learn how to create your own user groups today!

Community Connections 768x460.jpg

Community & How To Videos

Check out the new Power Platform Community Connections gallery!

M365 768x460.jpg

Microsoft 365 Collaboration Conference | December 7–9, 2021

Join us, in-person, December 7–9 in Las Vegas, for the largest gathering of the Microsoft community in the world.

Users online (1,404)