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

Parsing JSON to multiple rows in SQL server

I am using the JSON parsing tool with the goal of writing the response to a sql server table. It is getting parsed correctly, but it is only pulling the first object. The response will be multiple objects every time, so i would like to have a new row for each. I am able to do this in Power BI just find with the parse/convert to table. 

 

Any ideas? 

 

Sample return: (Rows would be for each ID)

 

"id_0":{"date_time":"2020-03-04 14:19:41","hostname":"test","server_name":"test","server_ip":"tes","unique_id":"1234","call_type":"t","source_num":"t","source_name":"","to":"t","dest_num":"t","dest_name":"","trunk_name":"t","duration":"t"},
"id_1":{"date_time":"2020-03-04 14:19:41","hostname":"test","server_name":"test","server_ip":"test","unique_id":"test","call_type":"t","source_num":"t","source_name":"","to":"t","dest_num":"t","dest_name":"t","trunk_name":"t","duration":"t"}

 

1 ACCEPTED SOLUTION

Accepted Solutions
v-alzhan-msft
Community Support
Community Support

Hi @thampton ,

 

Have you managed to insert the row to SQL Server?

As @ChristianAbata  asked, could you please share a screenshot of the configuration of your flow?

 

You could take a try with the schema below:

{
    "type": "object",
    "properties": {
        "date_time": {
            "type": "string"
        },
        "hostname": {
            "type": "string"
        },
        "server_name": {
            "type": "string"
        },
        "server_ip": {
            "type": "string"
        },
        "unique_id": {
            "type": "string"
        },
        "call_type": {
            "type": "string"
        },
        "source_num": {
            "type": "string"
        },
        "source_name": {
            "type": "string"
        },
        "to": {
            "type": "string"
        },
        "dest_num": {
            "type": "string"
        },
        "dest_name": {
            "type": "string"
        },
        "trunk_name": {
            "type": "string"
        },
        "duration": {
            "type": "string"
        }
    }
}

1.png

 

Best regards,

Alice       

 

Community Support Team _ Alice Zhang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

11 REPLIES 11
ChristianAbata
Super User
Super User

hi @thampton  you can try this.

aply.PNG



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

@ChristianAbata   Thank you ! Weird thing, when i go to select an output from previous steps, i get no dynamic content. However, at the end of my flow when i am inserting into SQL, the fields are available. 

@thampton  cloud you show us an screanshot?



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
v-alzhan-msft
Community Support
Community Support

Hi @thampton ,

 

Have you managed to insert the row to SQL Server?

As @ChristianAbata  asked, could you please share a screenshot of the configuration of your flow?

 

You could take a try with the schema below:

{
    "type": "object",
    "properties": {
        "date_time": {
            "type": "string"
        },
        "hostname": {
            "type": "string"
        },
        "server_name": {
            "type": "string"
        },
        "server_ip": {
            "type": "string"
        },
        "unique_id": {
            "type": "string"
        },
        "call_type": {
            "type": "string"
        },
        "source_num": {
            "type": "string"
        },
        "source_name": {
            "type": "string"
        },
        "to": {
            "type": "string"
        },
        "dest_num": {
            "type": "string"
        },
        "dest_name": {
            "type": "string"
        },
        "trunk_name": {
            "type": "string"
        },
        "duration": {
            "type": "string"
        }
    }
}

1.png

 

Best regards,

Alice       

 

Community Support Team _ Alice Zhang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

@v-alzhan-msft No i wasnt able to get this working, yet. It seems there is something wrong with my json response. If you use a json parser onlne, it is valid, but no dynamic content is shown. This is exactly how it is when i select show output. I need to be able to insert a row for each Id, but right now, if i want to loop through with apply to each, my only dynamic content is "Body". 

 

{"body":{"id_0":{"date_time":"2020-03-13 08:44:16","hostname":"test","server_name":"test","server_ip":"test.test","unique_id":"1234567","call_type":"testcall","source_num":"0","source_name":"","to":"0","dest_num":"0","dest_name":"Test","trunk_name":"0","duration":"115"}}}

 

Let me know if you can help, thanks in advance!

 

 

Hi @thampton ,

 

Could you please share a screenshot of the configuration of your flow?

 

Best regards,

Alice       

 

Community Support Team _ Alice Zhang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

@v-alzhan-msft  It looks like the config you had posted above. The only issue is the dynamic fields to not show up when you place an apply to each under the parse, so im not able to create a new row in SQL for each ID.

Hi @thampton ,

 

So I need the full screenshot of the configuration of your flow to reproduce your issue and help you.

 

I also need the full text you enter in the content field of the Parse JSON action.

 

Best regards,

Alice       

 

Community Support Team _ Alice Zhang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

@v-alzhan-msft Below is the screenshot of my config. The API returns the text below. The schema is also below. 

 

Config:

 

{"body":{"id_0":{"date_time":"2020-03-13 08:44:16","hostname":"test","server_name":"test","server_ip":"test.test","unique_id":"1234567","call_type":"testcall","source_num":"0","source_name":"","to":"0","dest_num":"0","dest_name":"Test","trunk_name":"0","duration":"115"}}}

 

Schema:

{
"type": "object",
"properties": {
"date_time": {
"type": "string"
},
"hostname": {
"type": "string"
},
"server_name": {
"type": "string"
},
"server_ip": {
"type": "string"
},
"unique_id": {
"type": "string"
},
"call_type": {
"type": "string"
},
"source_num": {
"type": "string"
},
"source_name": {
"type": "string"
},
"to": {
"type": "string"
},
"dest_num": {
"type": "string"
},
"dest_name": {
"type": "string"
},
"trunk_name": {
"type": "string"
},
"duration": {
"type": "string"
}
}
}
 
 
When i try to use an apply to each, so i can loop through each unique ID (bolded above) and insert a row per each, no dynamic content is available.

@v-alzhan-msft  It wont let me attach screenshot, but config is below:

 

1. Frequency : 1 hour

2. Customer connector : Calls API and returns the body above. 

3. Parse : using the schema above

Hi @thampton ,

 

Input in the Compose:

 

{"body":{"id_0":{"date_time":"2020-03-13 08:44:16","hostname":"test","server_name":"test","server_ip":"test.test","unique_id":"1234567","call_type":"testcall","source_num":"0","source_name":"","to":"0","dest_num":"0","dest_name":"Test","trunk_name":"0","duration":"115"}}}

 

 

Expression in the Compose 2:

 

outputs('Compose')?['Body']?['id_0']

 

 

Schema:

 

{
    "type": "object",
    "properties": {
        "date_time": {
            "type": "string"
        },
        "hostname": {
            "type": "string"
        },
        "server_name": {
            "type": "string"
        },
        "server_ip": {
            "type": "string"
        },
        "unique_id": {
            "type": "string"
        },
        "call_type": {
            "type": "string"
        },
        "source_num": {
            "type": "string"
        },
        "source_name": {
            "type": "string"
        },
        "to": {
            "type": "string"
        },
        "dest_num": {
            "type": "string"
        },
        "dest_name": {
            "type": "string"
        },
        "trunk_name": {
            "type": "string"
        },
        "duration": {
            "type": "string"
        }
    }
}

 

 

The flow:

1.png

 

Best Regards,

Alice

 

Community Support Team _ Alice Zhang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Helpful resources

Announcements
UG GA Amplification 768x460.png

Launching new user group features

Learn how to create your own user groups today!

Community Connections 768x460.jpg

Community & How To Videos

Check out the new Power Platform Community Connections gallery!

Top Solution Authors
Top Kudoed Authors
Users online (1,269)