web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Automate / BATCH API fails at sch...
Power Automate
Answered

BATCH API fails at schema validation

(0) ShareShare
ReportReport
Posted on by 7

I have a batch API that is pulling staff information from our school management system. The API call works well in other applications, but in Power Automate there's something strange going on.

 

When running the flow, it gives me an error that the MiddleName field is expecting a string, but returning a null. In the dataset, there are some teachers with no middle name listed, so the field is null. This is making the flow fall over, but I am not sure how to fix this step.

 

I am looking to send the output from this into a Microsoft List so that teachers can look up the contact details of other staff (apparently looking in Outlook or the school management system is too hard for them, so maybe this will work for them...)

 

Below is JSON Schema based on the sample I provided to the flow from the sample.

 

 

{
 "type": "object",
 "properties": {
 "iSAMS": {
 "type": "object",
 "properties": {
 "HRManager": {
 "type": "object",
 "properties": {
 "CurrentStaff": {
 "type": "object",
 "properties": {
 "StaffMember": {
 "type": "array",
 "items": {
 "type": "object",
 "properties": {
 "@@Id": {
 "type": "string"
 },
 "@@PersonId": {
 "type": "string"
 },
 "@@PersonGuid": {
 "type": "string"
 },
 "Initials": {
 "type": "string"
 },
 "UserCode": {
 "type": "string"
 },
 "Title": {
 "type": "string"
 },
 "Forename": {
 "type": "string"
 },
 "MiddleNames": {
 "type": "string"
 },
 "Surname": {
 "type": "string"
 },
 "FullName": {
 "type": "string"
 },
 "NameInitials": {
 "type": "string"
 },
 "PreferredName": {
 "type": "string"
 },
 "Salutation": {
 "type": "string"
 },
 "DOB": {
 "type": "string"
 },
 "Gender": {
 "type": "string"
 },
 "SchoolEmailAddress": {
 "type": "string"
 },
 "SchoolMobileNumber": {},
 "PersonalMobileNumber": {},
 "TeachingStaff": {
 "type": "string"
 },
 "Divisions": {
 "type": "object",
 "properties": {
 "Division": {
 "type": "array",
 "items": {
 "type": "object",
 "properties": {
 "@@Id": {
 "type": "string"
 },
 "Name": {
 "type": "string"
 }
 },
 "required": [
 "@@Id",
 "Name"
 ]
 }
 }
 }
 },
 "Roles": {
 "type": "object",
 "properties": {
 "Role": {
 "type": "object",
 "properties": {
 "@@Id": {
 "type": "string"
 },
 "Name": {
 "type": "string"
 }
 }
 }
 }
 },
 "PreviousMISId": {
 "type": "string"
 },
 "UserName": {
 "type": "string"
 },
 "LeavingDate": {
 "type": "string"
 }
 },
 "required": [
 "@@Id",
 "@@PersonId",
 "@@PersonGuid",
 "Initials",
 "UserCode",
 "Title",
 "Forename",
 "Surname",
 "FullName",
 "NameInitials",
 "PreferredName",
 "Salutation",
 "DOB",
 "Gender",
 "SchoolEmailAddress",
 "SchoolMobileNumber",
 "TeachingStaff",
 "Divisions"
 ]
 }
 }
 }
 }
 }
 }
 }
 }
 }
}

 

 

Categories:
I have the same question (0)
  • Expiscornovus Profile Picture
    33,194 Most Valuable Professional on at

    Hi @Always_Flying,

     

    You can amend your parse json schema to allow null values for certain properties.

     

    April Dunnam has a nice blog about this approach:

    https://www.sharepointsiren.com/2018/10/flow-parse-json-null-error-fix/

     

    For example MiddleNames 

    "MiddleNames": { "type": "string" }

     

    Can be converted to something like below

    "MiddleNames": { "type": ["string","null"]}

      

  • Always_Flying Profile Picture
    7 on at

    @Expiscornovus thank you so much for that pointer!

     

    I applied that logic to the "MiddleNames" and several other fields, which have all worked. There was also a later array nested within an object that was originally object within object. Played around using those same principles, which appear to have worked for that step....

     

    And now we have another snag, which I feel is connected to the array within an object?

  • Verified answer
    Expiscornovus Profile Picture
    33,194 Most Valuable Professional on at

    Hi @Always_Flying,

     

    The Apply to each expects an array. However, the body is an object.

     

    As a workaround can you place square brackets around the body and try again?

     

    squarebrackets_workaround.png

  • Always_Flying Profile Picture
    7 on at

    Fantastic @Expiscornovus 

    That cracked it....

    I found that putting this snippet of code then removes it from being available to the list, so I removed the null from the type section...

    "MiddleNames": { "type": ["string","null"]}

    It then sprung into life!

     

    Thanks again!

     

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Automate

#1
Michael E. Gernaey Profile Picture

Michael E. Gernaey 503 Super User 2025 Season 2

#2
Tomac Profile Picture

Tomac 321 Moderator

#3
abm abm Profile Picture

abm abm 237 Most Valuable Professional

Last 30 days Overall leaderboard