Updated: Mar 29, 2019
In this post, let us look how we are going to handle the Office 365 SharePoint action errors that occurs on Microsoft Flow platform.
Problem Statement: There is an option to get the user profile property on Microsoft Flow using SharePoint REST API. We need to handle if there is any error to this action. Let us see how to handle/catch the error and send a mail with error details.
Sometime back I have published an article for updating user display names for items created on SharePoint using Microsoft Flow. We will use the same concept here, but only we will see how to catch and send the error details over mail.
The flow to get and update the user profile property is as follows.
Create a trigger to fire the flow whenever an item is created.
Create a SharePoint action “Send an HTTP request to SharePoint”, to get the user profile property details as explained in the article mentioned above.
Parse JSON data to get the exact required property (user display name).
Update the same item with author name field with the value retrieved.
The following steps shows how to configure the flow to handle the error and configuring appropriate send email action.Just after the “Send an HTTP request to SharePoint” action, add a parallel branch with an action.
In the parallel branch, add an “Send an email” action. In the action provide the necessary details like, email address, subject and body text.
From send an email action, click on more option (three dots). Select "Configure run after" option.
Configure the action to run once the "send an http request" action fails, as shown below. This is done be selecting has failed check box for the previous action. Click on done once configured.
Parallely parse JSON will have configure option set to "is successful".
Test the Flow for Error Handling:
To test the error flow, I have made changes in "send an http request" action to fail. I have just added the user claim id without encoding into the "send an http request" action. This will make the action to fail, since the user id is not encoded.
Test the flow by going to list and creating an item. After few movements, come back to the flow and check the status of items.