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

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
PP Bootcamp Carousel

Global Power Platform Bootcamp

Dive into the Power Platform stack with hands-on sessions and labs, virtually delivered to you by experts and community leaders.

secondImage

Power Platform Community Conference On Demand

Watch Nick Doelman's session from the 2020 Power Platform Community Conference on demand!

MPA Community Blog

Power Automate Community Blog

Check out the community blog page where you can find valuable learning material from community and product team members!

Users online (3,418)