Power Automate: How to reduce number of API calls on Power Automate
To saving number of API call is important on Power Automate because it is not a limitless feature, indeed has a cost. Each call are evaluate and increase call cost on the API. Let’s have look how we indulge these number of calls. (Please check Microsoft API calls document)
Create a flow: When trigger an item is created
Firstly, create a flow which is a triggered when trigger an item is created and connect to related inputs (I will use Share Point Online)
- Select Condition
- Type Has Attachments equal to true -instead of directly type as true, use Expression like true(), it is more understandable by Power Automate
- If yes, compose a message as Has Attachment, if no Has no Attachment
Let’s look at the Share Point list and create a record:
I created a record without adding any attachment to this record.
As you can see, the record was created and condition set false itself and compose “Has no attachment”
If I would add a record with an attachment, differently I will see the condition is going to set itself as true and will compose “Has attachment”
But the important point is these function will evaluated for each of these records, for an example if your list have a hundred records, so it will evaluate of each hundred records which have been created before (wasted hundred numbers of API call). It means too many requests by the Share Point list to the Power Automate.
Reducing Number of Calls
Now, let’s time to reduce number of these calls, but first do some basic adjustment before do that.
- Go to Power Automate Page
- Select View all Power Automate Settings
- Enable Experimental Feature
- Click on Save
After you enable this feature, you will see the fx icon that let you adding a condition within compose scope:
Click on it and add this expression:
equals(triggerOutputs()?[‘body/{HasAttachments}’, true])
Use equals expression and after that select Has Attachment dynamic content. End of this expression add as true because the condition in scope of true, apply same steps for no scope condition but do not forget set as false for this scope.
After completing this part, back to the flow trigger and do same adjust as well:
- Click on three dot and click on Settings (When an item is created)
- Add the same expression and click on Done
After completed those part, let’s back to the Share Point list and create two types of item: create a record with an attachment and versa versa (without attachment)
You will see out even adding two records this flow will evaluate only one item instead of working each of item, so you will not bother the flow through too much requests.
Thanks for reading !