How do i validate if the incoming JSON request body is a valid JSON (not against the schema) in Azure Logic App?

Sanjana Pushkar 201 Reputation points Microsoft Employee
2023-03-03T04:59:12.5966667+00:00

Hi, I have a Service Bus trigger which gets triggered every time a message is added to the topic. I need to validate if the incoming message is a valid JSON (not against the schema), and if not, it is passed to another service bus queue.

I can't seem to find a proper way to do that using logic apps, can someone help me in how it can be done.

Help would be much appreciated!

Azure Logic Apps
Azure Logic Apps
An Azure service that automates the access and use of data across clouds without writing code.
3,542 questions
0 comments No comments
{count} votes

Accepted answer
  1. MayankBargali-MSFT 70,936 Reputation points Moderator
    2023-03-03T05:44:12.64+00:00

    @Anonymous Thanks for reaching out. You can leverage the Parse JSON action to validate if the message content is valid JSON or not.

    In the below workflow I have leveraged the Parse JSON action and, in the content, I am converting my message content to base64ToString and for Schema specifying the empty JSON schema.

    Now in my condition I am checking whether my Parse JSON action failed or succeeded. I have configured run after behavior on my condition, so it is executed in both failed and successful scenario of my previous Parse JSON action. For actions please refer to this action.

    Syntax: actions('your action name').status

    Example: actions('Parse_JSON').status

    If my message content is valid JSON then the true condition will be executed and for not valid JSON false condition will be executed and you can further write your logic on true and false condition.

    User's image

    User's image

    User's image

    Let me know if you need any assistance.

    Please accept as "Yes" if the answer is helpful so that it can help others in the community. If you need any help/clarification/concerns/follow up questions, then please click on "Add Comment" on my answer and provide more details.


0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.