top of page
Writer's pictureShane Young

Intro to Power of APIs in Power Apps and Power Automate

Updated: Jul 21

Are you ready to take your Power Apps and Power Automate projects to the next level? APIs (Application Programming Interfaces) are your secret weapon, seamlessly integrating with various services like SharePoint, Outlook, Dataverse, and more. But if you're new to the world of APIs, fear not! This beginner's guide is designed to demystify APIs and show you how to harness their power in your low-code applications.


What is an API?

At its core, an API is a structured way to communicate with a system. It's the bridge that allows your Power Apps and Power Automate flows to talk to external services, fetching data, sending commands, and performing a myriad of tasks that extend the functionality of your applications. Think of it as a common language that your app uses to interact with the world outside its boundaries.




Why Should You Care About APIs?

APIs are everywhere, integrated into almost every digital service we use. By understanding and utilizing APIs, you can significantly enhance the capabilities of your Power Apps and Power Automate projects. From automating routine tasks to pulling in real-time data from external sources, APIs open up a world of possibilities for your applications.


Even if you look just a little under the covers in your Apps and flows today you will see they are using APIs to talk to your data sources like SharePoint. Look at the screenshot below where we use Monitor to look at the raw information that comes back when you Filter a Gallery. Thankfully Power Apps handles making this data useable but learning what it is doing opens a lot of doors to you doing bigger and badder things.



If you have no idea what that says, then this video and blog post are for you. There is a video that has a much deeper look at working with APIs and Json here: Intro to APIs for Power Apps and Power Automate


Getting Started with APIs

The easiest ways to use APIs with Power Apps and Power Automate is to use the HTTP action in a Power Automate Cloud flow. Here you will fill in the blanks from the API Documentation.

In the video I show using this documentation JSONPlaceholder - Guide (typicode.com) but you can use any API you want. After following the info in their Guide I get the following.



Method

Methods with APIs are how you communicate with APIs. The documentation will tell you which to use but understanding at a high level what each does makes the documentation easier to follow. The Methods are as follows:

  • Get: Retrieves data from a server at the specified resource.

  • Post: Sends data to a server to create a new resource.

  • Put: Updates a specific resource completely with the data provided.

  • Patch: Applies partial modifications to a resource.

  • Delete: Removes the specified resource from the server.

Headers and Queries

The Headers and Queries are dependent on the API. Often here you will add things like the format you want the request to be sent in like JSON or XML. And sometimes you will need to include things like authentication. Once again, the documentation will guide you. It isn't unusual not to have headers or queries. Not sure I have ever had queries.


Body

When you are sending info to the API this is the meat of your request. It is often blank on Get requests but most of the other requests this is where you are saying do this thing. From the example above we are doing a Post to create a new item and the Body contains the details that we want for our new item written in JSON format.


Working with JSON in APIs

JSON (JavaScript Object Notation) is the lingua franca of APIs. It's a lightweight data-interchange format that's easy for humans to read and write and easy for machines to parse and generate. Understanding JSON is crucial for working with APIs, as it's the format you'll use to send requests and receive responses.


JSON at its simplest is just text in curly brackets. Something like this

{
  "title": "foo",
  "body": "bar",
  "userId": 1
}

The {} signify that you are creating a record (item). In that record you then have a column called title and the value of that is foo. The body of your record is bar and the userID is set to 1. In the video we spend more time on this but if you ignore all of the {} and "" and : and just read it as fancy text then the info isn't that scary.


When working with APIs you will use JSON both in the request, our POST and in the response you get back from the API.



Above is the response we got back from performing the API POST in flow. At first glance it looks like chaos but is it really? If I asked you what was the Location can you figure it out? Take a second and just read the text.... isn't the location just

See, JSON doesn't have to be that scary.


Practical Examples

Let's dive into some practical examples to see APIs in action within Power Apps and Power Automate:

  • Fetching Data from SharePoint: Imagine you want to display a list of items from SharePoint in your Power App. By making an API request to SharePoint, you can retrieve the data and dynamically populate a gallery in your app.

  • Sending Data to Outlook: Need to automate email notifications? Use an API to send data from your Power App to Outlook, creating and sending emails automatically based on your app's logic.

  • Turning off my lights: What? Yeah, my light switch is an IOT device meaning it has an API. So I can write a flow to turn it on and off. This video shows it: Power Automate HTTP action, Rest API, and IOT


Tips for Success

  • Start Simple: Begin with straightforward API requests to get comfortable with the process.

  • Use Documentation: Leverage the extensive documentation available for most APIs to understand the required request formats and available endpoints.

  • Practice with Public APIs: Experiment with public APIs (like JSON Placeholder) to practice making requests and handling responses without worrying about authentication.


Conclusion

APIs are a powerful tool in the Power Apps and Power Automate ecosystem, offering endless possibilities for enhancing your applications. By understanding the basics of API communication and practicing with real-world examples, you'll be well on your way to unlocking the full potential of your low-code projects. Remember, the world of APIs is vast and varied, so never stop exploring and learning. Happy coding!


If you need help working with APIs and JSON in Power Apps and Power Automate then scroll down the page and fill out our Contact Us form. We are happy to help. 😎


3,321 views0 comments

Recent Posts

See All
bottom of page