Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Logic App - Create CSV table from JSON output

I've created a Runbook which starts or shutsdown VMs and then spits the result in a JSON output. I'm having trouble trying to figure out how to take that output and use it in a 'Create CSV Table' within my Logic App.

Output (which is exactly how it comes into the Logic App):

[
    {
        'VM':  'MyVM2',
        'Success':  true,
        'PSComputerName':  'localhost',
        'PSShowComputerName':  true,
        'PSSourceJobInstanceId':  '286eeccb-c7f6-4afd-a734-7f4e837ffdac'
    },
    {
        'VM':  'MyVM1',
        'Success':  true,
        'PSComputerName':  'localhost',
        'PSShowComputerName':  true,
        'PSSourceJobInstanceId':  '286eeccb-c7f6-4afd-a734-7f4e837ffdac'
    }
]

My Logic App flow: enter image description here

However I am prompted with the following error when it runs because the ‘Create CSV Table’ doesn’t like the input: enter image description here

I’m sure it’s just some sort of formatting that needs to be changed, but I am unsure how to do it. I'm new to learning code, and as far as I can tell the output is an Array of Objects, but the error is asking for an Array. Perhaps some sort of limitation?

I'm aware of using Pars JSON, however the results will not always be the same. Sometimes I will have 2 results in the output, or sometimes I will have 20 results. Therefore if I define the schema in Parse JSON for only 2 results, it will omit the rest because they are not defined.

like image 439
Beefcake Avatar asked Oct 25 '25 09:10

Beefcake


1 Answers

Apologies to those who have already answered the question, but during that time I was able to create a table a different way, and have since excessively progressed with my logic app.

Create_CSV_table": {
            "inputs": {
                "format": "CSV",
                "from": "@json(outputs('Compose'))"
            },

...and thus the output was like:

logic app

I hope that your answers will help others (or myself later on) for anyone viewing this page.

like image 179
Beefcake Avatar answered Oct 27 '25 15:10

Beefcake



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!