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

Parse JSON from emailed .txt attachment

Hello!

 

I wonder if anyone could help please? I'm attempting to parse JSON having not tried this before and encountering some difficlties.

 

The intention is that emails are received with individual .txt files attached containing JSON output. The JSON should be parsed and used to populate a SharePoint list.

 

I've got as far as setting up my flow whereby the attachment is succesfully processed from the email using 'Get Attachment', and then the attachment content is fed into the parse JSON action, and i've set up the JSON schema using a sample payload.

 

When I run the flow it fails at the parse JSON step:

 

InvalidJSON. The 'content' property of actions of type 'ParseJson' must be valid JSON. The provided value '[Long string of text here V3nfsnjfjenrngRYUYBBhbdj etc]=' cannot be parsed: 'Unexpected character encountered while parsing value: W. Path '', line 0, position 0.'.
 
It looks like I have to do some of process/conversion on the content of the .txt file to make it acceptable for the parse JSON action. Can anyone point me in the right direction please?
2 REPLIES 2
kojisaiki
Microsoft
Microsoft

You should get file contents into string variable.

Please try following steps:

 

1. Initialize string variable

2. Set file content into the above variable (Dynamic content "Attachments" is collection, so you should use "Apply to each")

kojisaiki_0-1593999608369.png

3. Parse string variable as JSON

kojisaiki_1-1593999641553.png

 

<Sample>

- Attachment file

kojisaiki_2-1593999675828.png

- Result

kojisaiki_3-1593999731477.png

kojisaiki_4-1593999741902.png

 

Nam117
Frequent Visitor

Dear 

I'm struggling in extracting the failure email addresses list from the postmaster email. This list is sometimes more than 1 email in email boby and text attachment as well.


For as example: the text below is in text attachment
Original-Recipient: <email1>
Action: failed
Diagnostic-Code: smtp; 442 Unable to determine IP address for delivery.
Remote-MTA: 0.0.0.0

Original-Recipient: <email2>
Action: failed
Diagnostic-Code: smtp; 442 Unable to determine IP address for delivery.
Remote-MTA: 0.0.0.0

Original-Recipient: <email3>
Action: failed
Diagnostic-Code: smtp; 442 Unable to deliver message within specified time.
Remote-MTA: 0.0.0.0

Original-Recipient: <email4>
Action: failed
Diagnostic-Code: smtp; 442 Unable to deliver message within specified time.
Remote-MTA: 0.0.0.0

 

I would like to get each email and update my excel row table. Appreciate with any help.

Thank you very much.

Best regards,

Nam

 

 

 

 

Helpful resources

Announcements
MPA User Group

Welcome to the User Group Public Preview

Check out new user group experience and if you are a leader please create your group

MBAS on Demand

Microsoft Business Applications Summit sessions

On-demand access to all the great content presented by the product teams and community members! #MSBizAppsSummit #CommunityRocks

MBAS Attendee Badge

Claim Your Badge & Digital Swag!

Check out how to claim yours today!

secondImage

Are Your Ready?

Test your skills now with the Cloud Skill Challenge.

Top Solution Authors
Users online (88,845)