How to Generate QR Codes in Power Automate

Do you want to create a QR code in your flow?

QR codes can be used to link information to a scannable image.

When the QR code image is scanned, it will show the user the linked information such as a website or text.

You might need to create this scannable QR code image in your flow based on some dynamic content.

This post will show you how to generate a QR code in Power Automate.

QR Code API

This solution for generating a QR code will rely on the QR code generator API.

https://api.qrserver.com/v1/create-qr-code/?size=150x150&data=<YourLinkedInfo>

This allows you to request a QR code image from the above URL where <YourLinkedInfo> is the data that you want to link to with the QR code. This can be text or a URL to a website.

Get QR Code with HTTP Request

In order to call the QR code API, you will need to use the HTTP action to perform a GET request on the API. This will return the QR code as an image in base 64.

  1. Add the HTTP action to your flow.
  2. Select the GET option for the Method.
https://api.qrserver.com/v1/create-qr-code/?size=150x150&data=
  1. Enter the above URL for the QR code API into the URI field.
  2. Append on the end of the URL the text or website address for which you want to generate the QR code. In this example, the website address is stored in a Compose action and then referenced by dynamic content at the end of the API.
{
  "$content-type": "image/png",
  "$content": "iVBORw0KGgoAAAANSUhEUgAAAJYAAACWAQMAAAAGz+OhAAAABlBMVEX///8AAABVwtN+AAAACXBIWXMAAA7EAAAOxAGVKw4bAAABFElEQVRIib2Wsa3DMAxET3Ch0iNoFC328R1t5lE0gkoVhhlStBEgSRkd4cav0emOpA18qU20diD3VHqyl/5z9qfnrPux7kgn0gMIJLaKgsXkAKmIFCaTlu32dKbe2+2Z7OW9avnIYxrzXlP20X9z2V3ZtLzN00ymWo5VRp2x/uvDYZq5NVqzzMUAkYksDbGOGOrWKQyuxQfLtAQO21pehhb3v1vyv2c4YOfGaj575gSmPo8r4xqpy/v5DFkNWK6+UhBoDC5HyvBeVxaDed1pqxxw2DDc93PxVdkpzL8Li63lcGuhMP/+yh6v2TqprGWbqjRiJ7IDOls6zYivf4HJbHhvzPbkJjVwmPea7pIoD+9uDvtSTyMT52tsm2y7AAAAAElFTkSuQmCC"
}

When you run this flow, you will see something similar to the above output from the HTTP action.

This is the image of the QR code in base 64.

@{body('HTTP')['$content']}

You can use the above expression to get only the content part of the output.

Create the QR Code Image File in SharePoint

Now that you have the image for your QR code, you will want to use it somewhere.

You can store it in SharePoint as an image.

  1. Add the Create file action from the SharePoint connector.
  2. Select the Site Address where you want to save the file.
  3. Select the Folder Path where you want to save the QR image.
  4. Enter a File Name for the file along with the correct png file type extension for the QR code image. If you are generating multiple QR codes in the flow, you will want to ensure this is a unique name.

The File Content used in the Create file action must be in binary format. But since the QR code returns an image in base 64, you will need to convert this to binary.

You can easily convert base 64 to binary with the base64ToBinary function.

@{base64ToBinary(body('HTTP')['$content'])}
  1. Add the above expression to the File Content field. This will convert the base 64 content from the HTTP action to binary.

When the flow runs, it will call the QR code API and create the QR image in a SharePoint folder.

Conclusions

QR codes are a handy way to link to data but there is no action in Power Automate to create them.

You can use the HTTP action with a QR code generating API and save the results in SharePoint.

The only trick is you first need to convert the base 64 results from the API to binary to save the image to SharePoint.

How will you use this QR code technique in your flows? Let me know in the comments!

    About the Author

    John MacDougall

    John MacDougall

    John is a Microsoft MVP and freelance consultant and trainer specializing in Excel, Power BI, Power Automate, Power Apps and SharePoint. You can find other interesting articles from John on his blog or YouTube channel.

    Related Articles

    Comments

    0 Comments

    Get the Latest Tech Tips

    Write For Us

    Are you a tech enthusiast with a talent for writing great content? Come write for us!

    Follow Us

    Follow us on social media to stay up to date with the latest in tech!