• Skip to main content
  • Skip to primary sidebar
  • Skip to footer
  • Home
  • Blog
  • Power Platform
    • Power Apps
    • Power Automate
    • Power BI
    • Power Virtual Agents
  • Dynamics 365
  • Azure
  • About Me
Joe Gill Logo

Joe Gill

Microsoft MVP - Power Platform Consultant

Home » Azure » Logic Apps » Json Schema Validation in Logic Apps and Flow

Json Schema Validation in Logic Apps and Flow

1st October 2018 by Joe Gill

You can create Logic Apps and Flow workflows that trigger on receipt of a Http request and optionally receive a Json payload. This technique can be used as an integration pattern in a B2B enviroment.  You can design your Json scheme specifically for your partners so that is is easy to use and understand.  This provides your integation partners with an API that abtracts the complexities and business logic of the underlying platforms from the calling system.  This is a good way of creating an API for Dynamics 365 rather than proving direct access to the Dynamics Web API which gives unrestricted accesss to the underlying entities.

In this example I created a Logic App  workflow accepts a Json message use the Json data received to creates a contact and account record in Dynamics 365.

Json Schema Validation in Logic Apps and Flow Joe Gill Dynamics 365 Consultant

I created this workflow by starting with a blank workflow and added a Request trigger and entered the sample Json below to generate the payload schema.

Json Schema Validation in Logic Apps and Flow Joe Gill Dynamics 365 Consultant

I then added actions to the workflow to create a contact and account record in Dynamics 365 using the data in the Json payload. In the create account action I have used the company parameter from the Http request Json and set the primary contact to the contact created in the first action.

Json Schema Validation in Logic Apps and Flow Joe Gill Dynamics 365 Consultant

I can now provide my integration partner with details of the Url and the Json schema to call the Workflow.  The issue with this is that there is no validation of the Json posted and if the endpoint is triggered without a payload we end up with empty records in Dynamics 365. A better way of handling this is to use a Json Schema tool to create a schema with validation. I created my own Json schema making the  three fields required and used this schema in my Logic App instead of the previously auto generated schema.

{
“$schema”: “http://json-schema.org/draft-04/schema#”,
“type”: “object”,
“properties”: {
“firstname”: {
“type”: “string”
},
“lastname”: {
“type”: “string”
},
“company”: {
“type”: “string”
}
},
  “required”: [
    “firstname”,
    “lastname”,
    “company”
  ]
}

I then selected setting on the Logic Apps Http Trigger

Json Schema Validation in Logic Apps and Flow Joe Gill Dynamics 365 Consultant

I then set Schema Valdiation to on

Json Schema Validation in Logic Apps and Flow Joe Gill Dynamics 365 Consultant

Now when I try call my Logic Apps workflow the Json payload is validated against the schema and the caller gets an error back to this effect.

Json Schema Validation in Logic Apps and Flow Joe Gill Dynamics 365 Consultant

Flow can also be also configured in exactly the same way to validate a Json Schema.

 

 

Share This On Social:
  • Tweet
  • Json Schema Validation in Logic Apps and Flow Joe Gill Dynamics 365 Consultant

Filed Under: Dynamics 365, Logic Apps, Power Automate, Power Platform Tagged With: dynamics 365, Flow, Logic Apps, Web API

Primary Sidebar

Popular Categories

  • Power Platform
    • Power Apps
    • Power Automate
    • Power Virtual Agents
  • Azure
    • Logic Apps
  • Dynamics 365
  • .NET
  • AI
  • SQL

More to See

Power Platform Requests – Base Request Capacity

17th December 2020 By Joe Gill

Power Automate Desktop

Power Automate Desktop – UI Flow

26th November 2020 By Joe Gill

Tweets

Footer

Joe Gill

Microsoft Business Applications MVP – Power Platform, Dynamics 365 and Azure.

An architect with over twenty years experience designing and developing technology solutions. Specializing in the Microsoft technology stack including Power Platform, Dynamics 365 and Azure. Microsoft MVP Profile

Connect on Social

Useful Links

  • Home
  • Blog
  • About Joe Gill
  • Power Platform
  • Dynamics 365
  • Azure

Featured Posts

Power Platform Requests – Base Request Capacity

Power Automate Desktop – UI Flow

MB-600 – Solution Architect – Supportability

AI Builder – Form Processing Layouts

© 2021 · Joe Gill