Cancel An Approval In Power Automate

Cancel An Approval In Power Automate

You can cancel an approval in Power Automate by using a single flow action. This ability is not included in the standard approvals actions. However, we can invoke an HTTP request to call the Microsoft Teams approvals API and cancel the request.

Table of Contents
• Introduction: The Cancel An Approval FlowChoose An Approval To Be CancelledGet The Approval Id For The Approval To Be CancelledMake A Connection To Microsoft Teams ApprovalsCancel An Approval In Power Automate Using An HTTP RequestRun The Cancel An Approval Flow In Power Automate




Introduction: The Cancel An Approval Flow

An employee at a financial services firm makes a travel request to their manager using Microsoft Teams approvals and then leaves the company. We will cancel the approval by creating a Power Automate flow.



Choose An Approval To Be Cancelled

An approval may only be cancelled when it is in requested status. Open Microsoft Teams approvals center and find a “requested” approval.



Or create a new approval request if there are no approvals with a requested status. Here’s an example that can be copied if needed.




Get The Approval Id For The Approval To Be Cancelled

To cancel an approval using Power Automate we will need to get the Approval’s unique ID. Go to make.powerautomate.com and navigate the Approvals table (in Dataverse). Search the table for the record with a matching Title. The unique identifier is located in the Approval field of the record.




Set The Approval ID And Flow Environment Variables

Now we have the information needed to make our Power Automate flow. Start a new instant flow and add an initialize variable step. Create a variable named varApprovalId and set the value to the unique identifier of the approval.

Then initialize another variable named varFlowEnvironment and set the value to the unique identifier of the current environment.



The unique identifier for the current environment can be obtained by using the following expression.

workflow()?['tags']?['environmentName']




Make A Connection To Microsoft Teams Approvals

An approval cannot be cancelled using the standard Microsoft Teams actions included in Power Automate. We will use the HTTP With Microsoft Entra ID (Pre-authorized) – Invoke An HTTP Request action to cancel an approval instead.

Upon adding the action we will be asked to setup a connection.



Use the following URL in both the Base Resource URL and Microsoft Entra ID Resource URI fields and press the Sign In button.

https://approvals.teams.microsoft.com




Cancel An Approval In Power Automate Using An HTTP Request

Fill-in the flow action with the following values to cancel the approval request.



Method:

DELETE



Url of the request:

https://approvals.teams.microsoft.com/api/cancelApproval/@{variables('varApprovalId')}?flowEnvironment=@{variables('varFlowEnvironment')}



Headers:

KeyValue
Acceptapplication/json




Run The Cancel An Approval Flow In Power Automate

That’s all it takes to cancel an approval using Power Automate. Save the flow and give it a test run.



After the flow is completed we can see the approval has been cancelled in the Teams Approvals Center.



And the cancellation, who performed and the timestamp are reflected in the approval details.




Questions?

If you have any questions or feedback about Cancel An Approval Flow In Power Automate please leave a message in the comments section below. You can post using your email address and are not required to create an account to join the discussion.

Matthew Devaney

Subscribe
Notify of
guest

22 Comments
Oldest
Newest
Inline Feedbacks
View all comments
Kurt Henderson
Kurt Henderson
27 days ago

Hi Matthew, This is a very needed solution so thank you for posting it. I do have a question though. Is the HTTP request in this solution a premium connector?

Ramos
Ramos
26 days ago

is there any way to post HTML with the approval creating on teams? similiter to this issue as adaptive cards is not an option

https://powerusers.microsoft.com/t5/Building-Flows/post-a-choice-of-options-as-the-Flow-bot-to-a-user-HTML-format/td-p/960391

Aris
Aris
26 days ago

Hello Matthew,

First of all thanks for sharing this great post.

I would like to ask if there is an opportunity to delete an approval.

Thanks.

Oliveira
Oliveira
26 days ago

Hi, is it possible to create/instantiate a flow in another environment?

Paul Carter
Paul Carter
25 days ago

Hi Kurt,

Incredibly useful, thankyou.

We’re getting this error on the HTTP Request action.

{“ErrorMessage”:”Exception thrown by dependency.”,”Properties”:{“message”:”Exception thrown by dependency.”,”status”:”Forbidden”,”innerMessage”:”ApprovalCancelAccessDenied”,”showUserExceptionMessage”:”False”}}

Do you know what causes this?

Shoeb Memon
Shoeb Memon
11 days ago
Reply to  Paul Carter

We are running into the same error when canceling approval requests using the HTTP action. We use a system admin account with a Teams license and a Power Automate premium license.

Lucas
Lucas
25 days ago

Is there any official documentation about this and other API methods relating to approvals? I can only find this blog post and some forum questions regarding this. I’m curious what else is possible using a Teams Approvals API.

Ramos
Ramos
24 days ago

why not to use this?

Screenshot 2024-06-05 111819.png
Jeroen de Haas
Jeroen de Haas
23 days ago

Hi, I am not sure what information/details to use for the workflow()?[‘tags’]?[‘environmentName’]

Doug Booth, Oregon State Hospital
Doug Booth, Oregon State Hospital
22 days ago

Thank you for this great example, Matthew. Sadly, I’m on a government tenant which does not allow me access to the underlying Dataverse tables. I think I’m SOL until MS exposes functionality to cancel an automation. Any pull you have to make that happen would be appreciated!

Angel Yactayo
Angel Yactayo
15 days ago

HI, nice solution to cancel approvals, there is another way to cancel it? Can’t use CDN because approvals requestor are external users without licence (guesters) using a sp list that triggers a flow approval, and I not sure where is saved the approval or approval request that i need to check approval state and cancel.

Iga
Iga
5 days ago

Hi Matthew, thank you for this!!! So helpful, you have no idea 🙂

Can we use the Invoke an HTTP request to also approve/reject approvals or only cancel them?