HomeAutomationPower Automate Desktop - Invoke Web Service

Power Automate Desktop – Invoke Web Service

Category

Date

read time

“I need to make an API call within Power Automate Desktop.”

-Almost Everyone

In this blog we will discuss how to use the Invoke Web Service action. Fair warning, every API call is a little bit different but using tools like Postman can help with guidance and testing. We will cover some basic principles along with a few ideas and use cases. In another article I discuss a similar usage of API but in a Cloud Flow. Let’s get automating!

The Power Platform consists of various actions and one of those actions is “Invoke Web Service”. In general, this is the easiest route when it comes to making an API call although you could construct the same using PowerShell. Either way Postman is your best friend with the all helpful code snippet feature. Here we can go for the convert if need be, and at the very least it’s a helpful tool to explore crafting the right call.

Postman Code Snippet

Back to business, lets look at this Invoke Web Service action. In general this message starts out with a POST to obtain a token. Examining the basic parts in this request we have some needed items that will help us Auth. Tenant, Client, and Secret. Keep in mind this depends on the Auth type as a requirement of the API. Once the credentials are obtained, the rest is fairly straight forward when it comes to obtaining the token. The parts:

  • URL: varies based of off the API
  • Method: POST
  • Accept: application/json
  • Content Type: application/x-www-form-urlencoded
  • Request Body: at this primary step this will consist of the most basic message to tell the destination who we are so we can get this darn thing called a token. We do this by providing the required credentials.

If done successfully you will obtain a response back in the variables indicated. StatusCode 200 response with your payload. Now you notice you get this messy nonsense back with more than what you are after.

Lets look at how we can get this into a tappable resource AND here is the Convert JSON to Custom Object Action. Simply feed your response into this action and it will parse the mess into a data table

Parse JSON
datatable

Happy Day. Now we can move along and use this in future request by calling the info given in the table.

Authorization: Bearer %tokenObject['access_token']%

If you are new to the world of API this might take a bit of digging in to figure out, but obtaining a token is usually the first part of the battle. From here you can move on to other methods and request to get the data you are after. Pass the token, parse the data, perform an action.

Michael Heath

Michael Heath is an enablement specialist with over 15 years of experience. His background in Education, Behavioral Neuroscience, Game Theory, and IT has afforded him a unique perspective and ability to provide creative transformative solutions for the modern workplace. From napkin ideation to law, Michael utilizes human-centered techniques to solve problems in a creative and innovative way. His design thinking methodologies have resulted in millions of hours saved by strategizing big wins around usage and adoption of the Microsoft Power Platform. In his spare time, Michael loves experiencing new places, cultures, and foods with his family. He also enjoys lacing up a pair of hiking boots and exploring the great outdoors.

Recent posts