0
votes

Can the Logic App HTTP Request trigger validate against a provided JSON Schema?

Added a minimal JSON schema to the Request Body JSON Schema, and I get the various element ...

"Correlation": {
  "id": "/properties/Correlation",
  "properties": {
    "CaseNumber": {
      "id": "/properties/Correlation/properties/CaseNumber",
      "type": "string"
    },
    "ProviderCaseNumber": {
      "id": "/properties/Correlation/properties/ProviderCaseNumber",
      "type": "string"
    }
  },
  "required": ["CaseNumber"],
  "type": "object"
}, ... etc. ...

Read through the blog post, Logic Apps – Json Schema Verify, which shows how to use an Azure Function to handle the validation.

BUT Json.NET Schema is now a commerical product

Is there anyway in the actual trigger to validate, and even better, return a 400 Bad Request?

1
What's the result of what you're currently trying?Chris Pietschmann
Valid and invalid messages flow through to subsequent actionsSteveC
Logic Apps only support xml validate at the moment, please submit an idea for json validate on aka.ms/logicapps-wish to help us prioritize.Derek Li
@DerekLi Looks like this is already planned ... feedback.azure.com/forums/287593-logic-apps/suggestions/…SteveC
You can use 'parse JSON' action as the first step in your logic app to validate the trigger payload. This will also allow you to return 400 Bad Request if the schema is invalid (by using a condition + response action)Szymon Wylezol

1 Answers

0
votes

It is now built-in

In the HTTP request triggers Settings, enable the "Schema Validation" option

Schema Validation
Validate request body against the schema provided. 
In case there is a mismatch, HTTP 400 will be returned.