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

Cannot set variable from Parsed JSON

I have a "When a HTTP request is received" trigger set up as the first step in my flow. I have a Parse JSON step that gets the body content of the received request. It parses it to a schema that I generated from a sample payload. I cannot seem to set/initialize a variable with any data from the parsed JSON. The variable that I am using is the customer first name. It shows up as blank or null even if there is data in the output section of Parse JSON. 

 

I am initializing the variable as a string and setting it to 

body('Parse_JSON')?['body']?['estimate']?['customer']?['first_name']

 

 

I have ran into a roadblock on this. Any help is appreciated!

 

Parse JSON Output:

 

{
    "body": {
        "event": "estimate.scheduled",
        "company_id": "5d99b484-c68c-4393-962d-bf3aac2514ce",
        "estimate": {
            "id": "csr_48efccec4eb54cdc998903ea1b76ecb7",
            "estimate_number": "5",
            "work_status": "scheduled",
            "customer": {
                "id": "cus_a6a2b9dc854747c8a9cbc053960460d7",
                "first_name": "Will",
                "last_name": "xxxxxx",
                "email": "xxxxxxxxx@gmail.com",
                "mobile_number": "5555555555",
                "home_number": null,
                "work_number": null,
                "company": null,
                "notifications_enabled": true,
                "tags": []
            },
            "address": {
                "id": "adr_6ba72fa2cd01462ca4e984230e67b368",
                "type": "service",
                "street": "xxx xxx Street",
                "street_line_2": null,
                "city": "xxxCity",
                "state": "OH",
                "zip": "xxxxx",
                "country": null
            },
            "work_timestamps": {
                "on_my_way_at": null,
                "started_at": null,
                "completed_at": null
            },
            "schedule": {
                "scheduled_start": "2021-11-30T21:30:00Z",
                "scheduled_end": "2021-11-30T22:30:00Z",
                "arrival_window": 0
            },
            "assigned_employees": [
                {
                    "id": "pro_d9ac17f383f84deab2acfcfc8078471f",
                    "first_name": "Will",
                    "last_name": "xxxxxx",
                    "email": "xxxxxxxxx@gmail.com",
                    "mobile_number": "5555555555",
                    "color_hex": "EF9159",
                    "avatar_url": "/assets/add_image_thumb.png",
                    "role": "field tech",
                    "tags": [],
                    "permissions": {
                        "can_add_and_edit_job": true,
                        "can_be_booked_online": true,
                        "can_call_and_text_with_customers": true,
                        "can_chat_with_customers": true,
                        "can_delete_and_cancel_job": true,
                        "can_edit_message_on_invoice": false,
                        "can_see_street_view_data": true,
                        "can_share_job": true,
                        "can_take_payment_see_prices": true,
                        "can_see_customers": true,
                        "can_see_full_schedule": true,
                        "can_see_future_jobs": true,
                        "can_see_marketing_campaigns": true,
                        "can_see_reporting": true,
                        "can_edit_settings": true,
                        "is_point_of_contact": false,
                        "is_admin": true
                    }
                }
            ],
            "options": [
                {
                    "id": "est_856e1f5668004df8914e5583e82088c4",
                    "name": "Option #1",
                    "option_number": "5",
                    "total_amount": 564200,
                    "approval_status": null,
                    "message_from_pro": null
                }
            ]
        }
    }
}

 

 

 

2021-11-29 13_38_43-Window.png

 

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
Expiscornovus
Super User
Super User

Hi @william_nr3,

 

Can you try:

outputs('Parse_JSON')?['body']?['estimate']?['customer']?['first_name']

 

Or:

body('Parse_JSON')?['estimate']?['customer']?['first_name']

View solution in original post

3 REPLIES 3
Pstork1
Dual Super User III
Dual Super User III

Double check your input and your schema.  I used the sample JSON you provided and it returns the first name using the JSON you supplied.  But my JSON schema looks a bit different from yours.

{
    "type""object",
    "properties": {
        "event": {
            "type""string"
        },
        "company_id": {
            "type""string"
        },
        "estimate": {
            "type""object",
            "properties": {
                "id": {
                    "type""string"
                },
                "estimate_number": {
                    "type""string"
                },
                "work_status": {
                    "type""string"
                },
                "customer": {
                    "type""object",
                    "properties": {
                        "id": {
                            "type""string"
                        },
                        "first_name": {
                            "type""string"
                        },
                        "last_name": {
                            "type""string"
                        },
                        "email": {
                            "type""string"
                        },
                        "mobile_number": {
                            "type""string"
                        },
                        "home_number": {},
                        "work_number": {},
                        "company": {},
                        "notifications_enabled": {
                            "type""boolean"
                        },
                        "tags": {
                            "type""array"
                        }
                    }
                },
                "address": {
                    "type""object",
                    "properties": {
                        "id": {
                            "type""string"
                        },
                        "type": {
                            "type""string"
                        },
                        "street": {
                            "type""string"
                        },
                        "street_line_2": {},
                        "city": {
                            "type""string"
                        },
                        "state": {
                            "type""string"
                        },
                        "zip": {
                            "type""string"
                        },
                        "country": {}
                    }
                },
                "work_timestamps": {
                    "type""object",
                    "properties": {
                        "on_my_way_at": {},
                        "started_at": {},
                        "completed_at": {}
                    }
                },
                "schedule": {
                    "type""object",
                    "properties": {
                        "scheduled_start": {
                            "type""string"
                        },
                        "scheduled_end": {
                            "type""string"
                        },
                        "arrival_window": {
                            "type""integer"
                        }
                    }
                },
                "assigned_employees": {
                    "type""array",
                    "items": {
                        "type""object",
                        "properties": {
                            "id": {
                                "type""string"
                            },
                            "first_name": {
                                "type""string"
                            },
                            "last_name": {
                                "type""string"
                            },
                            "email": {
                                "type""string"
                            },
                            "mobile_number": {
                                "type""string"
                            },
                            "color_hex": {
                                "type""string"
                            },
                            "avatar_url": {
                                "type""string"
                            },
                            "role": {
                                "type""string"
                            },
                            "tags": {
                                "type""array"
                            },
                            "permissions": {
                                "type""object",
                                "properties": {
                                    "can_add_and_edit_job": {
                                        "type""boolean"
                                    },
                                    "can_be_booked_online": {
                                        "type""boolean"
                                    },
                                    "can_call_and_text_with_customers": {
                                        "type""boolean"
                                    },
                                    "can_chat_with_customers": {
                                        "type""boolean"
                                    },
                                    "can_delete_and_cancel_job": {
                                        "type""boolean"
                                    },
                                    "can_edit_message_on_invoice": {
                                        "type""boolean"
                                    },
                                    "can_see_street_view_data": {
                                        "type""boolean"
                                    },
                                    "can_share_job": {
                                        "type""boolean"
                                    },
                                    "can_take_payment_see_prices": {
                                        "type""boolean"
                                    },
                                    "can_see_customers": {
                                        "type""boolean"
                                    },
                                    "can_see_full_schedule": {
                                        "type""boolean"
                                    },
                                    "can_see_future_jobs": {
                                        "type""boolean"
                                    },
                                    "can_see_marketing_campaigns": {
                                        "type""boolean"
                                    },
                                    "can_see_reporting": {
                                        "type""boolean"
                                    },
                                    "can_edit_settings": {
                                        "type""boolean"
                                    },
                                    "is_point_of_contact": {
                                        "type""boolean"
                                    },
                                    "is_admin": {
                                        "type""boolean"
                                    }
                                }
                            }
                        },
                        "required": [
                            "id",
                            "first_name",
                            "last_name",
                            "email",
                            "mobile_number",
                            "color_hex",
                            "avatar_url",
                            "role",
                            "tags",
                            "permissions"
                        ]
                    }
                },
                "options": {
                    "type""array",
                    "items": {
                        "type""object",
                        "properties": {
                            "id": {
                                "type""string"
                            },
                            "name": {
                                "type""string"
                            },
                            "option_number": {
                                "type""string"
                            },
                            "total_amount": {
                                "type""integer"
                            },
                            "approval_status": {},
                            "message_from_pro": {}
                        },
                        "required": [
                            "id",
                            "name",
                            "option_number",
                            "total_amount",
                            "approval_status",
                            "message_from_pro"
                        ]
                    }
                }
            }
        }
    }
}


-------------------------------------------------------------------------
If I have answered your question, please mark your post as Solved.
If you like my response, please give it a Thumbs Up.
Expiscornovus
Super User
Super User

Hi @william_nr3,

 

Can you try:

outputs('Parse_JSON')?['body']?['estimate']?['customer']?['first_name']

 

Or:

body('Parse_JSON')?['estimate']?['customer']?['first_name']

View solution in original post

Both work. Interesting- the extra body was thrown in there automatically when selecting dynamic content. Thanks a ton. 

Helpful resources

Announcements
Community Connections 768x460.jpg

Community & How To Videos

Check out the new Power Platform Community Connections gallery!

User Group Leader Meeting January 768x460.png

Calling all User Group Leaders!

Don't miss the User Group Leader meetings on January, 24th & 25th, 2022.

Top Solution Authors
Top Kudoed Authors
Users online (2,716)