cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
Frequent Visitor

Parse JSON Arary from HTTP Body

Hi All,

 

I am trying to parse a JSON response I get but struggling to do so. Any help would be appreciated, Thanks.

 

Content:

[
{
"id": 13598,
"name": "Sandbox Test Project",
"display_name": "1234 - Sandbox Test Project",
"project_number": "1234",
"address": "6309 Carpinteria Avenue",
"city": "Carpinteria",
"state_code": "CA",
"country_code": "US",
"zip": "93013",
"county": "Santa Barbara County",
"time_zone": "US/Pacific",
"latitude": 34.3850438,
"longitude": -119.4908492,
"stage": "None",
"phone": null,
"created_at": "2020-01-14T00:40:02Z",
"updated_at": "2020-01-14T00:41:14Z",
"active": true,
"origin_id": null,
"origin_data": null,
"origin_code": null,
"estimated_value": null,
"project_region_id": null,
"project_bid_type_id": null,
"project_owner_type_id": null,
"photo_id": 307004,
"company": {
"id": 24588,
"name": "My Procore App"
}
},
{
"id": 13577,
"name": "Standard Project Template",
"display_name": "Standard Project Template",
"project_number": null,
"address": null,
"city": null,
"state_code": null,
"country_code": null,
"zip": null,
"county": null,
"time_zone": "US/Pacific",
"latitude": null,
"longitude": null,
"stage": "None",
"phone": null,
"created_at": "2020-01-14T00:30:00Z",
"updated_at": "2020-01-14T00:30:02Z",
"active": true,
"origin_id": null,
"origin_data": null,
"origin_code": null,
"estimated_value": null,
"project_region_id": null,
"project_bid_type_id": null,
"project_owner_type_id": null,
"photo_id": null,
"company": {
"id": 24588,
"name": "My Procore App"
}
}
]
 
JSON Schema
{
"type": "array",
"items": {
"type": "object",
"properties": {
"id": {
"type": "integer"
},
"name": {
"type": "string"
},
"display_name": {
"type": "string"
},
"project_number": {
"type": "string"
},
"address": {
"type": "string"
},
"city": {
"type": "string"
},
"state_code": {
"type": "string"
},
"country_code": {
"type": "string"
},
"zip": {
"type": "string"
},
"county": {
"type": "string"
},
"time_zone": {
"type": "string"
},
"latitude": {
"type": "number"
},
"longitude": {
"type": "number"
},
"stage": {
"type": "string"
},
"phone": {},
"created_at": {
"type": "string"
},
"updated_at": {
"type": "string"
},
"active": {
"type": "boolean"
},
"origin_id": {},
"origin_data": {},
"origin_code": {},
"estimated_value": {},
"project_region_id": {},
"project_bid_type_id": {},
"project_owner_type_id": {},
"photo_id": {
"type": "integer"
},
"company": {
"type": "object",
"properties": {
"id": {
"type": "integer"
},
"name": {
"type": "string"
}
}
}
},
"required": [
"id",
"name",
"display_name",
"project_number",
"address",
"city",
"state_code",
"country_code",
"zip",
"county",
"time_zone",
"latitude",
"longitude",
"stage",
"phone",
"created_at",
"updated_at",
"active",
"origin_id",
"origin_data",
"origin_code",
"estimated_value",
"project_region_id",
"project_bid_type_id",
"project_owner_type_id",
"photo_id",
"company"
]
}
}
 
Output:
[
{
"message": "Invalid type. Expected String but got Null.",
"lineNumber": 0,
"linePosition": 0,
"path": "[1].project_number",
"schemaId": "#/items/properties/project_number",
"errorType": "type",
"childErrors": []
},
{
"message": "Invalid type. Expected String but got Null.",
"lineNumber": 0,
"linePosition": 0,
"path": "[1].address",
"schemaId": "#/items/properties/address",
"errorType": "type",
"childErrors": []
},
{
"message": "Invalid type. Expected String but got Null.",
"lineNumber": 0,
"linePosition": 0,
"path": "[1].city",
"schemaId": "#/items/properties/city",
"errorType": "type",
"childErrors": []
},
{
"message": "Invalid type. Expected String but got Null.",
"lineNumber": 0,
"linePosition": 0,
"path": "[1].state_code",
"schemaId": "#/items/properties/state_code",
"errorType": "type",
"childErrors": []
},
{
"message": "Invalid type. Expected String but got Null.",
"lineNumber": 0,
"linePosition": 0,
"path": "[1].country_code",
"schemaId": "#/items/properties/country_code",
"errorType": "type",
"childErrors": []
},
{
"message": "Invalid type. Expected String but got Null.",
"lineNumber": 0,
"linePosition": 0,
"path": "[1].zip",
"schemaId": "#/items/properties/zip",
"errorType": "type",
"childErrors": []
},
{
"message": "Invalid type. Expected String but got Null.",
"lineNumber": 0,
"linePosition": 0,
"path": "[1].county",
"schemaId": "#/items/properties/county",
"errorType": "type",
"childErrors": []
},
{
"message": "Invalid type. Expected Number but got Null.",
"lineNumber": 0,
"linePosition": 0,
"path": "[1].latitude",
"schemaId": "#/items/properties/latitude",
"errorType": "type",
"childErrors": []
},
{
"message": "Invalid type. Expected Number but got Null.",
"lineNumber": 0,
"linePosition": 0,
"path": "[1].longitude",
"schemaId": "#/items/properties/longitude",
"errorType": "type",
"childErrors": []
},
{
"message": "Invalid type. Expected Integer but got Null.",
"lineNumber": 0,
"linePosition": 0,
"path": "[1].photo_id",
"schemaId": "#/items/properties/photo_id",
"errorType": "type",
"childErrors": []
}
]
 
 
 
 

Capture.PNGCapture2.PNG

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted

Hi

If your HTTP output is an array of objects, I would add an 'Apply to each' just after 'HTTP' action block, using 'HTTP' output as its input.

THen I would move 'Parse JSON' inside the apply to each,using item() as its input.

Please also note if you are currently grabbing the JSON stuff from somewhere else, you can use 'PArse JSON' option called “Use sample payload to generate schema“ and inject one of your current example objects to build the JSON schema:

 

{
"id": 13598,
"name": "Sandbox Test Project",
"display_name": "1234 - Sandbox Test Project",
"project_number": "1234",
"address": "6309 Carpinteria Avenue",
"city": "Carpinteria",
"state_code": "CA",
"country_code": "US",
"zip": "93013",
"county": "Santa Barbara County",
"time_zone": "US/Pacific",
"latitude": 34.3850438,
"longitude": -119.4908492,
"stage": "None",
"phone": null,
"created_at": "2020-01-14T00:40:02Z",
"updated_at": "2020-01-14T00:41:14Z",
"active": true,
"origin_id": null,
"origin_data": null,
"origin_code": null,
"estimated_value": null,
"project_region_id": null,
"project_bid_type_id": null,
"project_owner_type_id": null,
"photo_id": 307004,
"company": {
"id": 24588,
"name": "My Procore App"
}
}

 

Hope this helps



Each time you click on any of our inspiring answers 'Thumb up' icon...
...an ewok scapes from the stormtroopers.

Be grateful, Thumbs up! Save the Galaxy for free!


Escribo sobre Power Automate en:
https://medium.com/anyone-can-automate/

Proud to be a Flownaut!



View solution in original post

3 REPLIES 3
Highlighted
Super User III
Super User III

hi @thomas1992UK  are you receiving this response from your HTTP? What I can see is that you have multiples json roots, please see this web page https://jsonformatter.curiousconcept.com/. What you can do is try changing your API to send just 1 valid json root.



Did I answer your question? Please consider to Mark
my post as a solution! to guide others :winking_face:

Proud to be a Flownaut!


If you want you can follow me at www.christianabata.com Quieres contenido en español? Síguenos en Power Automate LA
Highlighted

Hi @ChristianAbata - thanks or your reply. How do I get just one response? The error message is now saying it is an array, Capture4.PNGI have updated the schema too the below:

{
"type": "object",
"properties": {
"id": {
"type": "integer"
},
"name": {
"type": "string"
},
"display_name": {
"type": "string"
},
"project_number": {
"type": "string"
},
"address": {
"type": "string"
},
"city": {
"type": "string"
},
"state_code": {
"type": "string"
},
"country_code": {
"type": "string"
},
"zip": {
"type": "string"
},
"county": {
"type": "string"
},
"time_zone": {
"type": "string"
},
"latitude": {
"type": "number"
},
"longitude": {
"type": "number"
},
"stage": {
"type": "string"
},
"phone": {},
"created_at": {
"type": "string"
},
"updated_at": {
"type": "string"
},
"active": {
"type": "boolean"
},
"origin_id": {},
"origin_data": {},
"origin_code": {},
"estimated_value": {},
"project_region_id": {},
"project_bid_type_id": {},
"project_owner_type_id": {},
"photo_id": {
"type": "integer"
},
"company": {
"type": "object",
"properties": {
"id": {
"type": "integer"
},
"name": {
"type": "string"
}
}
}
}
}
Highlighted

Hi

If your HTTP output is an array of objects, I would add an 'Apply to each' just after 'HTTP' action block, using 'HTTP' output as its input.

THen I would move 'Parse JSON' inside the apply to each,using item() as its input.

Please also note if you are currently grabbing the JSON stuff from somewhere else, you can use 'PArse JSON' option called “Use sample payload to generate schema“ and inject one of your current example objects to build the JSON schema:

 

{
"id": 13598,
"name": "Sandbox Test Project",
"display_name": "1234 - Sandbox Test Project",
"project_number": "1234",
"address": "6309 Carpinteria Avenue",
"city": "Carpinteria",
"state_code": "CA",
"country_code": "US",
"zip": "93013",
"county": "Santa Barbara County",
"time_zone": "US/Pacific",
"latitude": 34.3850438,
"longitude": -119.4908492,
"stage": "None",
"phone": null,
"created_at": "2020-01-14T00:40:02Z",
"updated_at": "2020-01-14T00:41:14Z",
"active": true,
"origin_id": null,
"origin_data": null,
"origin_code": null,
"estimated_value": null,
"project_region_id": null,
"project_bid_type_id": null,
"project_owner_type_id": null,
"photo_id": 307004,
"company": {
"id": 24588,
"name": "My Procore App"
}
}

 

Hope this helps



Each time you click on any of our inspiring answers 'Thumb up' icon...
...an ewok scapes from the stormtroopers.

Be grateful, Thumbs up! Save the Galaxy for free!


Escribo sobre Power Automate en:
https://medium.com/anyone-can-automate/

Proud to be a Flownaut!



View solution in original post

Helpful resources

Announcements
Community Conference

Power Platform Community Conference

Check out the on demand sessions that are available now!

Power Platform ISV Studio

Power Platform ISV Studio

ISV Studio is designed to become the go-to Power Platform destination for ISV’s to monitor & manage published applications.

Top Solution Authors
Top Kudoed Authors
Users online (11,149)