Skip to main content

Notifications

Community site session details

Community site session details

Session Id :
Power Automate - Using Flows
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"
 ]
 }
 }
 }
 }
 }
 }
 }
 }
 }
}

 

 

  • Always_Flying Profile Picture
    7 on at
    Re: BATCH API fails at schema validation

    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!

     

  • Verified answer
    Expiscornovus Profile Picture
    31,635 Most Valuable Professional on at
    Re: BATCH API fails at schema validation

    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
    Re: BATCH API fails at schema validation

    @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?

  • Expiscornovus Profile Picture
    31,635 Most Valuable Professional on at
    Re: BATCH API fails at schema validation

    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"]}

      

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

🌸 Community Spring Festival 2025 Challenge 🌸

WIN Power Platform Community Conference 2025 tickets!

Markus Franz – Community Spotlight

We are honored to recognize Markus Franz as our April 2025 Community…

Kudos to the March Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard

#1
WarrenBelz Profile Picture

WarrenBelz 146,552 Most Valuable Professional

#2
RandyHayes Profile Picture

RandyHayes 76,287 Super User 2024 Season 1

#3
Pstork1 Profile Picture

Pstork1 65,928 Most Valuable Professional

Leaderboard

Featured topics

Restore a deleted flow