cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Super User
Super User

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
Super User
Super User

Re: Convert API Response to .png

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

Super User
Super User

Re: Convert API Response to .png

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!

Highlighted
Super User
Super User

Re: Convert API Response to .png

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?

Super User
Super User

Re: Convert API Response to .png

@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
firstImage

Microsoft Business Applications Virtual Launch Event

Watch the event on demand for an in-depth look at the new innovations across Dynamics 365 and the Microsoft Power Platform.

firstImage

Watch Sessions On Demand!

Continue your learning in our online communities.

Power Platform 2019 Release Wave 2 Plan

Power Platform 2019 Release Wave 2 Plan

Features releasing from October 2019 through March 2020.

thirdimage

Flow Community User Group Member Badge

Fill out a quick form to claim your user group badge now!

fifthimage

Microsoft Learn

Learn how to build the business apps that you need.

sixthImage

Power Platform World Tour

Find out where you can attend!

seventhimage

Webinars & Video Gallery

Watch & learn from the Flow Community Video Gallery!

Users Online
Currently online: 178 members 5,224 guests
Please welcome our newest community members: