Logic App not able to deserialized Azure data factory pipeline error message

HemantSudehely-0557 261 Reputation points
2020-07-31T23:09:31.993+00:00

Hi,

I am facing the below issue with Azure Data Factory using Logic App.

I am using the Azure Data Factory pipeline for migration and Logic App for sending "Success & Failure" notification to the technical team.
Now success is working fine as the message is hardcoded, but failure is not as the Logic App web activity is not able to parse data factory pipeline error.

Here is the input that is going to Logic App web activity
Input
{
"url": "https://xxxxxxxxxxxxxxxxx",
"method": "POST",
"headers": {},
"body": "{\n \"title\": \"PIPELINE RUN FAILED\",\n \"message\":\"Operation on target Migration Validation failed: Execution fail against sql server. Sql error number: 50000. Error Message: The DELETE statement conflicted with the REFERENCE constraint \"FK_cmclientapprovedproducts_cmlinkclientchannel\". The conflict occurred in database \"Core7\", table \"dbo.cmClientApprovedProducts\", column 'linkclientchannelid'.\",\n \"color\": \"Red\",\n \"dataFactoryName\": \"LFC-TO-MCP-ADF\",\n \"pipelineName\": \"LFC TO MCP MIGRATION\",\n \"pipelineRunId\": \"f4f84365-58f0-4da1-aa00-64c3a4daa9e1\",\n \"time\": \"2020-07-31T22:44:01.6477435Z\"\n}"
}

Here is the error logic app is throwing

failures
{
"errorCode": "2108",
"message": "{\"error\":{\"code\":\"InvalidRequestContent\",\"message\":\"The request content is not valid and could not be deserialized: 'After parsing a value an unexpected character was encountered: F. Path 'message', line 3, position 202.'.\"}}",
"failureType": "UserError",
"target": "Send Failed Notification",
"details": []
}

I have tried various options, like set variable and convert by using various existing methods (string, json, replace etc), but no luck
e.g @ hide (activity('LOS migration').Error.Message)
Struggling almost all day this...please suggest if anyone faced a similar issue...

Below is the data flow activity
14849-pipeline.png

14850-logic-app-parameters.png

Azure Migrate
Azure Migrate
A central hub of Azure cloud migration services and tools to discover, assess, and migrate workloads to the cloud.
717 questions
Azure Logic Apps
Azure Logic Apps
An Azure service that automates the access and use of data across clouds without writing code.
2,840 questions
Azure Data Factory
Azure Data Factory
An Azure service for ingesting, preparing, and transforming data at scale.
9,529 questions
0 comments No comments
{count} votes

Accepted answer
  1. HarithaMaddi-MSFT 10,126 Reputation points
    2020-08-03T08:59:13.11+00:00

    Hi @HemantSudehely-0557,

    Welcome to Microsoft Q&A Platform.

    Below is an approach I used to get dynamic error messages in mail using Logic App from Azure Data Factory, it worked. If the issue persists, please share your pipeline run id to investigate further.
    15080-logicappfailuremailadf.gif

    1 person found this answer helpful.

2 additional answers

Sort by: Most helpful
  1. Mark Zhukovsky 46 Reputation points
    2021-03-13T19:51:40.147+00:00

    For those coming here struggling with this terrible problem as I have for way longer than desired; for my case, I have found the solution, and I suspect it will work for many others.

    The answer lies in the content of the JSON - if what you are passing in has DOUBLE QUOTES, they need to be replaced with SINGLE quotes. It is the only thing that worked for me.

    E.g.:

    @string(replace(activity('Execute a failing Pipeline').error.message, '"',''''))
    

    Note that these look identical because the first one is a double quote (what we are replacing) within single quotes, and the second one (what we are replacing it with) is an escaped single quote (i.e. two single quotes in a row) within single quotes.

    What a nightmare. But finally got it to work.

    9 people found this answer helpful.

  2. Balaji J 0 Reputation points
    2023-02-14T11:35:10.91+00:00

    This is works fine. Thank you for providing resolution.

    0 comments No comments