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

44 Comments
Oldest
Newest
Inline Feedbacks
View all comments
Kurt Henderson
Kurt Henderson
6 months 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
6 months 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
6 months 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
6 months ago

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

Paul Carter
Paul Carter
6 months 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
6 months 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
6 months 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
6 months ago

why not to use this?

Screenshot 2024-06-05 111819.png
Jeroen de Haas
Jeroen de Haas
6 months 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
6 months 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
6 months 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.

Marcos F Marx
6 months ago

Hi Matthew, this article surely saved my day. Until now I was cancelling approvals with the Dataverse connector, by directly updating the approval row. While it was never supported, it worked well so far until now. The problem is that MS made some changes to the approvals functionality and now if you cancel things that way, the request appears cancelled to the user on teams, but the “Wait for an approval” component of the flow never gives an output and stays indefinitely on waiting status.
I replaced the dataverse update row by the API call as you suggested and it worked like a charm.
Thank you!

Iga
Iga
5 months 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?

Ken Sato
Ken Sato
5 months ago

Just curious, could you walk through how you managed to figure out the API calls/endpoints?

Stefano
Stefano
5 months ago

Hi Matthew,
great post thank you!
I try to reproduce your steps but I get an error on Http request box:

Bed request. Action 'Invoke_an_HTTP_request' failed: The route is missing a required provider name.

Trying the same step with GET instead DELETE and using /api/GetApprovalDetails/varName as path, it works.

What is wrong on delete? 🙁

Brigitte Labelle
Brigitte Labelle
5 months ago

Hi Matthew! What is the benefit of using this api call over updating the dataverse tables directly?

Rob Roach
Rob Roach
5 months ago

Hi Matthew, thanks for the post, very informative! From my testing this update only applies to the teams UI? The approval still appears in the persons Power Automate Approvals and is available to take action on (i.e. approve or reject). If correct or did I do something wrong?

Mohammed
Mohammed
4 months ago

Hi Matthew, I used your API call & it worked great. If I need to add a comment when the approval is being deleted, how is the “Body” of the HTTP action setup? I mean, is there a “Comments” field and is it an attribute or is it under other attributes?

Henry Smith
Henry Smith
4 months ago

Hi Matthew:

Is there an equivalent API endpoint for submitting a response to an approval (i.e. some URL that looks like “https://approvals.teams.microsoft.com/api/submitResponse/…”)?

I cannot seem to find any documentation on other actions that utilize the Approvals API in the way that you are using it.

Jacopo
Jacopo
3 months ago

Hi Matthew, thank you for this post. Is there any chance to use a non premium connector? The approval API has been rolled out?

Ben Dransfield
Ben Dransfield
3 months ago

I am getting a “The Response is not in a JSON format.” error. My guess is the service account I am running this does not have the necessary permissions. If I want to cancel this on behalf of another user, is there a 365 admin role that would grant the service account the necessary permissions?

Last edited 3 months ago by Ben Dransfield