Using MS Flows, I am trying to create a list in Sharepoint from an Html list that I downloaded from a Web API. If I download an html with single user, the flow runs correctly. If i download an html with more than one user the flow stops during the Parse JSON step with the following error.
[
{
"message": "Invalid type. Expected Object but got Array.",
"lineNumber": 0,
"linePosition": 0,
"path": "PublicEmployeeResponse.Data.d2p1:PublicEmployee",
"schemaId": "#/properties/PublicEmployeeResponse/properties/Data/properties/d2p1:PublicEmployee",
"errorType": "type",
"childErrors": []
}
]​<p> </p><p>This is the schema I have that works with a single user. <li-code lang="markup">{
"type": "object",
"properties": {
"PublicEmployeeResponse": {
"type": "object",
"properties": {
"@@xmlns:i": {
"type": "string"
},
"@@xmlns": {
"type": "string"
},
"Count": {
"type": "string"
},
"Data": {
"type": "object",
"properties": {
"@@xmlns:d2p1": {
"type": "string"
},
"d2p1:PublicEmployee": {
"type": "object",
"properties": {
"d2p1:AgencyCode": {
"type": "string"
},
"d2p1:AlternativeFirstName": {
"type": "object",
"properties": {
"@@i:nil": {
"type": "string"
}
}
},
"d2p1:EmployeeType": {
"type": "string"
},
"d2p1:FirstName": {
"type": "string"
},
"d2p1:FormattedSupervisorName": {
"type": "string"
},
"d2p1:Grade": {
"type": "string"
},
"d2p1:Id": {
"type": "string"
},
"d2p1:IsActive": {
"type": "string"
},
"d2p1:LastName": {
"type": "string"
},
"d2p1:Location": {
"type": "string"
},
"d2p1:LocationId": {
"type": "string"
},
"d2p1:MiddleName": {
"type": "string"
},
"d2p1:MobilePhone": {
"type": "string"
},
"d2p1:MobilePhoneFormatted": {
"type": "string"
},
"d2p1:MobilePhoneIsForeign": {
"type": "string"
},
"d2p1:Office": {
"type": "string"
},
"d2p1:OfficePhone": {
"type": "string"
},
"d2p1:OfficePhoneFormatted": {
"type": "string"
},
"d2p1:OfficePhoneIsForeign": {
"type": "string"
},
"d2p1:OfficialEmail": {
"type": "string"
},
"d2p1:OrgCode": {
"type": "string"
},
"d2p1:OrgName": {
"type": "string"
},
"d2p1:Series": {
"type": "string"
},
"d2p1:Step": {
"type": "string"
},
"d2p1:StreetAddress": {
"type": "string"
},
"d2p1:SupervisorAlternativeFirstName": {
"type": "object",
"properties": {
"@@i:nil": {
"type": "string"
}
}
},
"d2p1:SupervisorEmail": {
"type": "string"
},
"d2p1:SupervisorEmployeeType": {
"type": "string"
},
"d2p1:SupervisorFirstName": {
"type": "string"
},
"d2p1:SupervisorId": {
"type": "string"
},
"d2p1:SupervisorLastName": {
"type": "string"
},
"d2p1:SupervisorMiddleName": {
"type": "string"
},
"d2p1:SupervisorMobilePhone": {
"type": "string"
},
"d2p1:SupervisorMobilePhoneFormatted": {
"type": "object",
"properties": {
"@@i:nil": {
"type": "string"
}
}
},
"d2p1:SupervisorMobilePhoneIsForeign": {
"type": "string"
},
"d2p1:SupervisorOfficialPhone": {
"type": "string"
},
"d2p1:SupervisorOfficialPhoneFormatted": {
"type": "object",
"properties": {
"@@i:nil": {
"type": "string"
}
}
},
"d2p1:SupervisorOfficialPhoneIsForeign": {
"type": "string"
},
"d2p1:SupervisorTitle": {
"type": "string"
},
"d2p1:Title": {
"type": "string"
},
"d2p1:UserPrincipalName": {
"type": "string"
}
}
}
}
},
"Message": {
"type": "object",
"properties": {
"@@i:nil": {
"type": "string"
}
}
},
"Total": {
"type": "string"
}
}
}
}
}
FINALLY!!. So I eded up adding the ["string","null"] to the schema, eventhough they dissapear from the dynamic list. However, under create item, I still added (items('Apply_to_each')['Name'] and it still pulls the items. Thank you, grantjenkins for all your help. I was able to understand how schema works a little bit more.
I think i found where the problem is coming from. I noticed that the xml when its empty looks like this:
<d2p1:AlternativeFirstName i:nil="true"/>
and when I dont get an error it looks like this:
<d2p1:AlternativeFirstName>Lue</d2p1:AlternativeFirstName>
So during conversions i see the following no closing statement.
<AlternativeFirstName i:nil=\"true\" />
AlternativeFirstName":{"@i:nil":"true"}
Thank you. I am getting the same error.
{"errors":[{"message":"Invalid type. Expected String but got Object.","lineNumber":0,"linePosition":0,"path":"[1].SupervisorAlternativeFirstName","schemaId":"#/items/properties/SupervisorAlternativeFirstName","errorType":"type","childErrors":[]},{"message":"Invalid type. Expected String but got Object.","lineNumber":0,"linePosition":0,"path":"[2].SupervisorAlternativeFirstName","schemaId":"#/items/properties/SupervisorAlternativeFirstName","errorType":"type","childErrors":[]},{"message":"Invalid type. Expected String but got Object.","lineNumber":0,"linePosition":0,"path":"[2].SupervisorEmail","schemaId":"#/items/properties/SupervisorEmail","errorType":"type","childErrors":[]},{"message":"Invalid type. Expected String but got Object.","lineNumber":0,"linePosition":0,"path":"[2].SupervisorFirstName","schemaId":"#/items/properties/SupervisorFirstName","errorType":"type","childErrors":[]},{"message":"Invalid type. Expected String but got
{
"type": "array",
"items": {
"type": "object",
"properties": {
"AgencyCode": {
"type": "string"
},
"AlternativeFirstName": {
"type": "object",
"properties": {
"@@i:nil": {
"type": "string"
}
}
},
"EmployeeType": {
"type": "string"
},
"FirstName": {
"type": "string"
},
"FormattedSupervisorName": {
"type": "string"
},
"Grade": {
"type": "string"
},
"Id": {
"type": "string"
},
"IsActive": {
"type": "string"
},
"LastName": {
"type": "string"
},
"Location": {
"type": "string"
},
"LocationId": {
"type": "string"
},
"MiddleName": {
"type": "string"
},
"MobilePhone": {
"type": "string"
},
"MobilePhoneFormatted": {
"type": "string"
},
"MobilePhoneIsForeign": {
"type": "string"
},
"Office": {
"type": "string"
},
"OfficePhone": {
"type": "string"
},
"OfficePhoneFormatted": {
"type": "string"
},
"OfficePhoneIsForeign": {
"type": "string"
},
"OfficialEmail": {
"type": "string"
},
"OrgCode": {
"type": "string"
},
"OrgName": {
"type": "string"
},
"Series": {
"type": "string"
},
"Step": {
"type": "string"
},
"StreetAddress": {
"type": "string"
},
"SupervisorAlternativeFirstName": {
"type": "string"
},
"SupervisorEmail": {
"type": "string"
},
"SupervisorEmployeeType": {
"type": "string"
},
"SupervisorFirstName": {
"type": "string"
},
"SupervisorId": {
"type": "string"
},
"SupervisorLastName": {
"type": "string"
},
"SupervisorMiddleName": {
"type": "string"
},
"SupervisorMobilePhone": {
"type": "string"
},
"SupervisorMobilePhoneFormatted": {
"type": "object",
"properties": {
"@@i:nil": {
"type": "string"
}
}
},
"SupervisorMobilePhoneIsForeign": {
"type": "string"
},
"SupervisorOfficialPhone": {
"type": "string"
},
"SupervisorOfficialPhoneFormatted": {
"type": "object",
"properties": {
"@@i:nil": {
"type": "string"
}
}
},
"SupervisorOfficialPhoneIsForeign": {
"type": "string"
},
"SupervisorTitle": {
"type": "string"
},
"Title": {
"type": "string"
},
"UserPrincipalName": {
"type": "string"
}
},
"required": [
"AgencyCode",
"AlternativeFirstName",
"EmployeeType",
"FirstName",
"FormattedSupervisorName",
"Grade",
"Id",
"IsActive",
"LastName",
"Location",
"LocationId",
"MiddleName",
"MobilePhone",
"MobilePhoneFormatted",
"MobilePhoneIsForeign",
"Office",
"OfficePhone",
"OfficePhoneFormatted",
"OfficePhoneIsForeign",
"OfficialEmail",
"OrgCode",
"OrgName",
"Series",
"Step",
"StreetAddress",
"SupervisorAlternativeFirstName",
"SupervisorEmail",
"SupervisorEmployeeType",
"SupervisorFirstName",
"SupervisorId",
"SupervisorLastName",
"SupervisorMiddleName",
"SupervisorMobilePhone",
"SupervisorMobilePhoneFormatted",
"SupervisorMobilePhoneIsForeign",
"SupervisorOfficialPhone",
"SupervisorOfficialPhoneFormatted",
"SupervisorOfficialPhoneIsForeign",
"SupervisorTitle",
"Title",
"UserPrincipalName"
]
}
}
Can you try running the flow again then copying all the output from Compose Public Employee, then use that to generate a new Schema for the Parse JSON action and see if that resolves the issue?
Once again thank you so much. I had an issue removing the d2pi part but I solved it by adding a compose/expression of 'string'. The flow worked flawless with the sample of two I provided. But once i tried the one with more employees i started getting the null message again when trying to Parse JSON.
{"errors":[{"message":"Invalid type. Expected String but got Object.","lineNumber":0,"linePosition":0,"path":"[1].SupervisorAlternativeFirstName","schemaId":"#/items/properties/SupervisorAlternativeFirstName","errorType":"type","childErrors":[]},{"message":"Invalid type. Expected String but got Object.","lineNumber":0,"linePosition":0,"path":"[2].SupervisorAlternativeFirstName","schemaId":"#/items/properties/SupervisorAlternativeFirstName","errorType":"type","childErrors":[]},{"message":"Invalid type. Expected String but got Object.","lineNumber":0,"linePosition":0,"path":"
....etc
[324].SupervisorAlternativeFirstName","schemaId":"#/items/properties/SupervisorAlternativeFirstName","errorType":"type","childErrors":[]},{"message":"Invalid type. Expected String but got Object.","lineNumber":0,"linePosition":0,"path":"[326].SupervisorAlternativeFirstName","schemaId":"#/items/properties/SupervisorAlternativeFirstName","errorType":"type","childErrors":[]}]}
I think it's because your raw XML is actual XML (mine was just a string that looked like XML).
Can you try the following expression and see if it works:
replace(string(outputs('XML')), 'd2p1:', '')
Oh my god, thanks for taking the time and giving me such great and detail explanation. But I am getting one of those object errors trying to remove the d2pi part.
Unable to process template language expressions in action 'Remove_d2pi' inputs at line '0' and column '0': 'The template language function 'replace' expects its first parameter 'string' to be a string. The provided value is of type 'Object'.
I think I might have something that works, including removing the d2p1: from each property. See below:
The full flow is below. I'll go into each action.
Compose XML is just the raw data that you provided for the two employees.
Compose Remove d2p1: strips out any instances of the text d2p1: so you get nicer property names. The expression I use here is:
replace(outputs('Compose_XML'), 'd2p1:', '')
Compose JSON converts the XML to JSON. Note that it wraps an xml expression within a json expression as so:
json(xml(outputs('Compose_Remove_d2p1:')))
Compose Public Employee allows us to just return the PublicEmployee array of objects which is all we want. The expression is:
outputs('Compose_JSON')?['PublicEmployeeResponse/Data/PublicEmployee']
Finally, we use Parse JSON using the schema that was generated from the Compose Public Employee Output.
The Schema is:
{
"type": "array",
"items": {
"type": "object",
"properties": {
"AgencyCode": {
"type": "string"
},
"AlternativeFirstName": {
"type": "object",
"properties": {
"@@i:nil": {
"type": "string"
}
}
},
"EmployeeType": {
"type": "string"
},
"FirstName": {
"type": "string"
},
"FormattedSupervisorName": {
"type": "string"
},
"Grade": {
"type": "string"
},
"Id": {
"type": "string"
},
"IsActive": {
"type": "string"
},
"LastName": {
"type": "string"
},
"Location": {
"type": "string"
},
"LocationId": {
"type": "string"
},
"MiddleName": {
"type": "string"
},
"MobilePhone": {
"type": "string"
},
"MobilePhoneFormatted": {
"type": "string"
},
"MobilePhoneIsForeign": {
"type": "string"
},
"Office": {
"type": "string"
},
"OfficePhone": {
"type": "string"
},
"OfficePhoneFormatted": {
"type": "string"
},
"OfficePhoneIsForeign": {
"type": "string"
},
"OfficialEmail": {
"type": "string"
},
"OrgCode": {
"type": "string"
},
"OrgName": {
"type": "string"
},
"Series": {
"type": "string"
},
"Step": {
"type": "string"
},
"StreetAddress": {
"type": "string"
},
"SupervisorAlternativeFirstName": {
"type": "string"
},
"SupervisorEmail": {
"type": "string"
},
"SupervisorEmployeeType": {
"type": "string"
},
"SupervisorFirstName": {
"type": "string"
},
"SupervisorId": {
"type": "string"
},
"SupervisorLastName": {
"type": "string"
},
"SupervisorMiddleName": {
"type": "string"
},
"SupervisorMobilePhone": {
"type": "string"
},
"SupervisorMobilePhoneFormatted": {
"type": "object",
"properties": {
"@@i:nil": {
"type": "string"
}
}
},
"SupervisorMobilePhoneIsForeign": {
"type": "string"
},
"SupervisorOfficialPhone": {
"type": "string"
},
"SupervisorOfficialPhoneFormatted": {
"type": "object",
"properties": {
"@@i:nil": {
"type": "string"
}
}
},
"SupervisorOfficialPhoneIsForeign": {
"type": "string"
},
"SupervisorTitle": {
"type": "string"
},
"Title": {
"type": "string"
},
"UserPrincipalName": {
"type": "string"
}
},
"required": [
"AgencyCode",
"AlternativeFirstName",
"EmployeeType",
"FirstName",
"FormattedSupervisorName",
"Grade",
"Id",
"IsActive",
"LastName",
"Location",
"LocationId",
"MiddleName",
"MobilePhone",
"MobilePhoneFormatted",
"MobilePhoneIsForeign",
"Office",
"OfficePhone",
"OfficePhoneFormatted",
"OfficePhoneIsForeign",
"OfficialEmail",
"OrgCode",
"OrgName",
"Series",
"Step",
"StreetAddress",
"SupervisorAlternativeFirstName",
"SupervisorEmail",
"SupervisorEmployeeType",
"SupervisorFirstName",
"SupervisorId",
"SupervisorLastName",
"SupervisorMiddleName",
"SupervisorMobilePhone",
"SupervisorMobilePhoneFormatted",
"SupervisorMobilePhoneIsForeign",
"SupervisorOfficialPhone",
"SupervisorOfficialPhoneFormatted",
"SupervisorOfficialPhoneIsForeign",
"SupervisorTitle",
"Title",
"UserPrincipalName"
]
}
}
I've added an Apply to each just to test the output that we get is working and correct.
I removed all the original data from this xml and shrunk it to two employees. I thought i was getting the error for the null values but i fill all entries and I still get the error. It does parse but it will not create the items, giving me that null error.
<PublicEmployeeResponse xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://schemas.datacontract.org/2004/07/WebTele.Web.Features.PublicEmployeeApi.Common">
<Count>2</Count>
<Data xmlns:d2p1="http://schemas.datacontract.org/2004/07/WebTele.Application.Domain.Entities">
<d2p1:PublicEmployee>
<d2p1:AgencyCode>QA</d2p1:AgencyCode>
<d2p1:AlternativeFirstName i:nil="true" />
<d2p1:EmployeeType>Walmart</d2p1:EmployeeType>
<d2p1:FirstName>SAM</d2p1:FirstName>
<d2p1:FormattedSupervisorName>Test, Charles</d2p1:FormattedSupervisorName>
<d2p1:Grade>Sales</d2p1:Grade>
<d2p1:Id>aaaaaa</d2p1:Id>
<d2p1:IsActive>true</d2p1:IsActive>
<d2p1:LastName>Galigan</d2p1:LastName>
<d2p1:Location>Chicago</d2p1:Location>
<d2p1:LocationId>1111</d2p1:LocationId>
<d2p1:MiddleName>A</d2p1:MiddleName>
<d2p1:MobilePhone>0000000000</d2p1:MobilePhone>
<d2p1:MobilePhoneFormatted>(000) 000-0000</d2p1:MobilePhoneFormatted>
<d2p1:MobilePhoneIsForeign>false</d2p1:MobilePhoneIsForeign>
<d2p1:Office>Toys</d2p1:Office>
<d2p1:OfficePhone>0000000000</d2p1:OfficePhone>
<d2p1:OfficePhoneFormatted>(000) 000-0000</d2p1:OfficePhoneFormatted>
<d2p1:OfficePhoneIsForeign>false</d2p1:OfficePhoneIsForeign>
<d2p1:OfficialEmail>SamGaligan@Walmart.com</d2p1:OfficialEmail>
<d2p1:OrgCode>0000000000000000</d2p1:OrgCode>
<d2p1:OrgName>Walmart000</d2p1:OrgName>
<d2p1:Series>1111</d2p1:Series>
<d2p1:Step>1</d2p1:Step>
<d2p1:StreetAddress>111 Walmart St</d2p1:StreetAddress>
<d2p1:SupervisorAlternativeFirstName>Sammy</d2p1:SupervisorAlternativeFirstName>
<d2p1:SupervisorEmail>SamWalter@Walmart.com</d2p1:SupervisorEmail>
<d2p1:SupervisorEmployeeType>None</d2p1:SupervisorEmployeeType>
<d2p1:SupervisorFirstName>Sam</d2p1:SupervisorFirstName>
<d2p1:SupervisorId>bbbbbbb</d2p1:SupervisorId>
<d2p1:SupervisorLastName>Walter</d2p1:SupervisorLastName>
<d2p1:SupervisorMiddleName>j</d2p1:SupervisorMiddleName>
<d2p1:SupervisorMobilePhone>0000000000</d2p1:SupervisorMobilePhone>
<d2p1:SupervisorMobilePhoneFormatted i:nil="true" />
<d2p1:SupervisorMobilePhoneIsForeign>false</d2p1:SupervisorMobilePhoneIsForeign>
<d2p1:SupervisorOfficialPhone>0000000000</d2p1:SupervisorOfficialPhone>
<d2p1:SupervisorOfficialPhoneFormatted i:nil="true" />
<d2p1:SupervisorOfficialPhoneIsForeign>false</d2p1:SupervisorOfficialPhoneIsForeign>
<d2p1:SupervisorTitle>Supervisor</d2p1:SupervisorTitle>
<d2p1:Title>Sales Man</d2p1:Title>
<d2p1:UserPrincipalName>12345aaaa</d2p1:UserPrincipalName>
</d2p1:PublicEmployee>
<d2p1:PublicEmployee>
<d2p1:AgencyCode>QA</d2p1:AgencyCode>
<d2p1:AlternativeFirstName i:nil="true" />
<d2p1:EmployeeType>Sales</d2p1:EmployeeType>
<d2p1:FirstName>Charlie</d2p1:FirstName>
<d2p1:FormattedSupervisorName>Walters, Test</d2p1:FormattedSupervisorName>
<d2p1:Grade>as</d2p1:Grade>
<d2p1:Id>ppssos8</d2p1:Id>
<d2p1:IsActive>true</d2p1:IsActive>
<d2p1:LastName>Strips</d2p1:LastName>
<d2p1:Location>Texas</d2p1:Location>
<d2p1:LocationId>2222</d2p1:LocationId>
<d2p1:MiddleName>B</d2p1:MiddleName>
<d2p1:MobilePhone>1111111111</d2p1:MobilePhone>
<d2p1:MobilePhoneFormatted>(111) 111-1111</d2p1:MobilePhoneFormatted>
<d2p1:MobilePhoneIsForeign>false</d2p1:MobilePhoneIsForeign>
<d2p1:Office>Texas</d2p1:Office>
<d2p1:OfficePhone>1111111111</d2p1:OfficePhone>
<d2p1:OfficePhoneFormatted>(000) 111-1000</d2p1:OfficePhoneFormatted>
<d2p1:OfficePhoneIsForeign>false</d2p1:OfficePhoneIsForeign>
<d2p1:OfficialEmail>testr@walmart.com</d2p1:OfficialEmail>
<d2p1:OrgCode>0000000000000000</d2p1:OrgCode>
<d2p1:OrgName>Walmart000</d2p1:OrgName>
<d2p1:Series>1111</d2p1:Series>
<d2p1:Step>1</d2p1:Step>
<d2p1:StreetAddress>111 Walmart St</d2p1:StreetAddress>
<d2p1:SupervisorAlternativeFirstName>Sammy</d2p1:SupervisorAlternativeFirstName>
<d2p1:SupervisorEmail>SamWalter@Walmart.com</d2p1:SupervisorEmail>
<d2p1:SupervisorEmployeeType>None</d2p1:SupervisorEmployeeType>
<d2p1:SupervisorFirstName>Sam</d2p1:SupervisorFirstName>
<d2p1:SupervisorId>bbbbbbb</d2p1:SupervisorId>
<d2p1:SupervisorLastName>Walter</d2p1:SupervisorLastName>
<d2p1:SupervisorMiddleName>j</d2p1:SupervisorMiddleName>
<d2p1:SupervisorMobilePhone>0000000000</d2p1:SupervisorMobilePhone>
<d2p1:SupervisorMobilePhoneFormatted i:nil="true" />
<d2p1:SupervisorMobilePhoneIsForeign>false</d2p1:SupervisorMobilePhoneIsForeign>
<d2p1:SupervisorOfficialPhone>0000000000</d2p1:SupervisorOfficialPhone>
<d2p1:SupervisorOfficialPhoneFormatted i:nil="true" />
<d2p1:SupervisorOfficialPhoneIsForeign>false</d2p1:SupervisorOfficialPhoneIsForeign>
<d2p1:SupervisorTitle>Supervisor</d2p1:SupervisorTitle>
<d2p1:Title>Sales Man</d2p1:Title>
<d2p1:UserPrincipalName>12345bbbbb</d2p1:UserPrincipalName>
</d2p1:PublicEmployee>
</Data>
<Message i:nil="true" />
<Total>0</Total>
</PublicEmployeeResponse>
Michael E. Gernaey
497
Super User 2025 Season 2
David_MA
436
Super User 2025 Season 2
Riyaz_riz11
244
Super User 2025 Season 2