cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
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
Highlighted
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

Highlighted
Dual Super User III
Dual Super User III

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

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?

Highlighted

@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
Community Conference

Power Platform Community Conference

Check out the on demand sessions that are available now!

Power Platform ISV Studio

Power Platform ISV Studio

ISV Studio is designed to become the go-to Power Platform destination for ISV’s to monitor & manage published applications.

Users online (12,789)