PowerAutomate QuickBits 2 – Handling APIs Efficiently

You get an API! You get an API! Everyone gets an API!

Hey everyone! Welcome back to another installment of our QuickBit series. This time, we’re looking at how to easily utilize APIs in PowerAutomate.

What is an API?

API stands for “Application Programming Interface”. An API acts as a sort of middle man for requests you wish to make to an endpoint. For a deeper understanding, have a look at this link.

The main reason we want to use an API is so we don’t reinvent the wheel. If you can think of something, there’s usually an API for it. Some interesting examples include:

Today, we’re going to be picking one from the above list, and one of my personal favourite APIs.

“I’m a creative genius.”  – Kanye

Time to build our Flow.

You guessed it, we’re using the Kanye API!
This API will provide you a random Kanye quote when you query it.

HTTP Calls – how to tell the API what to do:

When you query an API, you will be using different methods depending on what you would like to do. The main ones you may use are GET, POST and DELETE.

  • GET is used to request data from a specified resource
  • POST is used to send data to a server, or to create a resource.
  • DELETE is used to delete the specified resource

More information can be found here: HTTP Methods
Can you guess which one we’re going to use?

Implementing the GET method in Flow.

Let’s get into it! What we’ll be doing in this tutorial is setting up a flow that, every day at 8am, will grab a random Kanye quote and post it to yourself in teams! What a way to get motivated for your day.

First, create a new scheduled Flow. Name the flow, and set it to run every morning at 8am:
Schedule Setup

Click create, and then add a HTTP Step:

Add HTTP Step

Perfect! Now, the “Method” section is where we pick our HTTP method, as described before. Set it to GET, and in the URI add in:

https://api.kanye.rest/

HTTP Kanye Setup

Awesome, well done so far! Lets grab the content that we need and send it to Teams. Add the “Post a message ass the Flow bot to a user” step, and fill it out as so:

Teams Kanye Setup

We’re almost done! Lets run a test and see what it looks like.

Teams message Kanye quote

Oooh, so close! That’s okay, I’ll show you how to fix this so it displays just the quote, none of that weird curly brace stuff (which is JSON by the way, check it out here……PowerPlatform and JSON).

Back into Flow, we only need to do one simple thing! In the message section of your “Post a message as the Flow bot to a user” step, set the “Message” to this (make sure you’re in the expressions tab when adding this!):

body(‘HTTP’)[‘quote’]
Run the test again, and lets see what we’ve got:
Genius text Kanye quote
 

Wow! Thanks Kanye, I couldn’t have put it better myself.?

Closing thoughts

Think of the possibilities now! You can use ANY API you want to like this, and pull data into PowerAutomate. And once it’s in PowerAutomate, your options are endless.

Check out some of our other content here:

Cheers
Jacob | Automation Specialist

Leave a Reply

Your email address will not be published. Required fields are marked *