question

HectorMHJimenez-7899 avatar image
0 Votes"
HectorMHJimenez-7899 asked MayankBargali-MSFT commented

JSON Parse Fail with Azure Automation output

the powershell output for the runbook on automation account is not a json , how can modify it to get it in json parse logic app connector?

194356-image.png

194248-pic1.png194328-pic-2.jpg194340-pic5.png194329-pic4-li.jpg


azure-logic-apps
image.png (17.2 KiB)
pic1.png (22.9 KiB)
pic-2.jpg (191.1 KiB)
pic5.png (28.7 KiB)
pic4-li.jpg (185.3 KiB)
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

MayankBargali-MSFT avatar image
0 Votes"
MayankBargali-MSFT answered MayankBargali-MSFT commented

@HectorMHJimenez-7899 Thanks for reaching out. As per the output below I can see that the output field is not a valid JSON as you can see.
Account: value
Environment: value
...

195413-image.png

Further looking into your second screenshot that you have shared I can see the output is text value and looks like it has the valid JSON section (yellow highlighted text) inside the array value.
The starting text (red highlighted text) is not a valid JSON and when you use Parse JSON action then it fails as expected as your output is not valid JSON object.

195452-image.png

To make your output as the valid JSON object either you need to update the job and it should only return the valid JSON text (yellow highlighted text).

In case if you are not able to return the valid JSON object from your job then you can either leverage the split function to split your text and get the yellow highlighted text and then pass the right JSON object to your Parse JSON action. Alternatively, you can leverage the inline function and write the regular expression to get the right JSON value content.

Feel free to get back to me if you have any queries or concerns.


image.png (91.7 KiB)
image.png (27.0 KiB)
· 2
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Thank you for the response Mayank , it worked using inline function to get the right Json file.

0 Votes 0 ·

@HectorMHJimenez-7899 Thanks for your response and glad to know that it has helped. Feel free to get back to us in Microsoft Q&A if you need any assistance in future.

0 Votes 0 ·
AndrewBlumhardt-1137 avatar image
0 Votes"
AndrewBlumhardt-1137 answered HectorMHJimenez-7899 commented

I have not worked specifically with these connector activities. A few tips that may help:

Most of the activities produce JSON output and all expect JSON input. You can see the JSON output in the run logs. Errors related to JSON formatting are often a generic reference to a configuration error in the preceding activity. This could be misinterpreted as the need for a JSON parser. I would take a closer look at the "Get Job Output" config and logs.

As you may know, the template for a JSON parser can be taken from the output of the previous activity. Usually, the only time you need a JSON parser is following a generic HTTP request activity. Are you sure you need a JSON parser? Maybe there is an issue with the runbook?

· 2
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

This is the correct output

194249-pic6.png


0 Votes 0 ·
pic6.png (22.6 KiB)

Thanks for the response, im trying to send the output information from my powershell script of the automation account by email to end users, that is the reason taht im using json parser to get the fields and put into the email body, not sure if exist a different way to get the output in csv format and send it to end users by email.

Thank you

0 Votes 0 ·