0

I am trying to capture the error from failed activity in a variable activity or in web request activity for sending email. I am using “@activity().error.message” to capture it. It is throwing the attached error.

Any help is appreciated to resolve this. Thank you.

error message

Web Activity dynamic content: enter image description here

BPQ
  • 55
  • 1
  • 7

1 Answers1

0

Please try to use this expression:

@activity('Activity name').Error.Message

Update

I test this expression and it works fine.

enter image description here

enter image description here

enter image description here

Steve Johnson
  • 8,057
  • 1
  • 6
  • 17
  • @PPP I update my answer. You can have a try. – Steve Johnson Jan 19 '21 at 05:14
  • Thank you @SteveZhao . I am able to set the variable fine. But the email task is failing with the same error when I am using that variable in the message. I am using a file as source from network path. \\wint05\share\filepath. The file is not there. Do you think “\\” could be the issue? – BPQ Jan 19 '21 at 13:53
  • @PPP Based on your description, “\\” could be the issue. If you provide more details, we can fix this error more accurately – Steve Johnson Jan 20 '21 at 01:22
  • I have a file in network path I want to load. If the copy activity fails, I want to send the email. Now the file is missing in below path. **\\wint05\share\Team\Src\SampleText.txt** The error in copy activity is below: **ErrorCode=UserErrorUnexcepetedFileIOError,'Type=Microsoft.DataTransfer.Common.Shared.HybridDeliveryException,Message=Error occurred when trying to access the file in Folder '\\wint05\share\Team\Src\SampleText.txt', File filter: ''.,Source=Microsoft.DataTransfer.ClientLibrary,''Type=System.IO.IOException,Message=The user name or password is incorrect. ,Source=mscorlib,'** – BPQ Jan 20 '21 at 01:49
  • When I capture this in a set variable the message shows below. It matches with the above error expect the file path has additional "\"s in file path. Output: **{ "name": "ErrTxt", "value": "ErrorCode=UserErrorUnexcepetedFileIOError,'Type=Microsoft.DataTransfer.Common.Shared.HybridDeliveryException,Message=Error occurred when trying to access the file in Folder '\\\\wint05\\share\\Team\\Src\\SampleText.txt', File filter: ''.,Source=Microsoft.DataTransfer.ClientLibrary,''Type=System.IO.IOException,Message=The user name or password is incorrect.\r\n,Source=mscorlib,'" }** – BPQ Jan 20 '21 at 01:50
  • Now I am trying to use the variable in web request activity to construct email body. It is giving below error: Error code: 2108 Troubleshooting guide Failure type: User configuration issue Details: **{"error":{"code":"InvalidRequestContent","message":"The request content is not valid and could not be deserialized: 'Bad JSON escape sequence: \\D. Path 'message', line 3, position 196.'."}}** Source: Pipeline email_notification @Steve Zhao – BPQ Jan 20 '21 at 01:50
  • So there are two errors. One occurred during the copy activity and another one occurred during the web activity. Based on the first error message, have you checked your user name or password is correct? Then the second error shows that your request content isn't a valid JSON data, please check it. – Steve Johnson Jan 20 '21 at 02:43
  • First error in the copy activity is a test case for failure scenario. I want to capture the error message. For that it is giving the bad JSON error – BPQ Jan 20 '21 at 02:46
  • I see. Please edit your question and provide your screenshot of the setting of web activity. – Steve Johnson Jan 20 '21 at 02:49
  • Done. "message":"@{variables('ErrTxt')}", is giving the error. Tried it without the set variable also. I am still getting same error message: **"message":"@{activity('FileCopyEmailTest').Error.Message}",** – BPQ Jan 20 '21 at 02:53
  • @PPP I have tested on my side. It seems there is something wrong when you parse JSON data of request's body. – Steve Johnson Jan 20 '21 at 05:56
  • Was it successful on your end? – BPQ Jan 20 '21 at 20:19
  • Yes, I can get error message in my web application. – Steve Johnson Jan 20 '21 at 23:45
  • In that case something for Microsoft to fix? – BPQ Jan 20 '21 at 23:51