cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
sudosaurus
Level: Powered On

Flow PDF not attaching correctly.

Hello,

I have designed a logic web app workflow that attaches a PDF document from a SharePoint Online document library and then sends an email. However when the PDF is received the attachment appears truncated.

I have been reading on other forums that maybe the content type is not being detected for the PDF and others have said they believe Logic Web Apps is corrupting the document. For the record this works correctly when using Microsoft Flow.


See below the code view of my logic web app workflow. Hopefully someone can help. 

Thanks.

 

{
    "$connections": {
        "value": {
            "office365": {
                "connectionId": "/subscriptions/8020fe0f-d64e-462a-8e68-84cd02709dc4/resourceGroups/People-Services/providers/Microsoft.Web/connections/office365",
                "connectionName": "office365",
                "id": "/subscriptions/8020fe0f-d64e-462a-8e68-84cd02709dc4/providers/Microsoft.Web/locations/uksouth/managedApis/office365"
            },
            "sharepointonline": {
                "connectionId": "/subscriptions/8020fe0f-d64e-462a-8e68-84cd02709dc4/resourceGroups/People-Services/providers/Microsoft.Web/connections/sharepointonline",
                "connectionName": "sharepointonline",
                "id": "/subscriptions/8020fe0f-d64e-462a-8e68-84cd02709dc4/providers/Microsoft.Web/locations/uksouth/managedApis/sharepointonline"
            }
        }
    },
    "definition": {
        "$schema": "https://schema.management.azure.com/providers/Microsoft.Logic/schemas/2016-06-01/workflowdefinition.json#",
        "actions": {
            "Get_file_content": {
                "inputs": {
                    "host": {
                        "connection": {
                            "name": "@parameters('$connections')['sharepointonline']['connectionId']"
                        }
                    },
                    "method": "get",
                    "path": "/datasets/@{encodeURIComponent(encodeURIComponent('https://ondomain.sharepoint.com/sites/Reward'))}/files/@{encodeURIComponent(triggerBody()?['{Identifier}'])}/content",
                    "queries": {
                        "inferContentType": true
                    }
                },
                "runAfter": {
                    "Get_file_metadata": [
                        "Succeeded"
                    ]
                },
                "type": "ApiConnection"
            },
            "Get_file_metadata": {
                "inputs": {
                    "host": {
                        "connection": {
                            "name": "@parameters('$connections')['sharepointonline']['connectionId']"
                        }
                    },
                    "method": "get",
                    "path": "/datasets/@{encodeURIComponent(encodeURIComponent('https://ondomain.sharepoint.com/sites/Reward'))}/files/@{encodeURIComponent(triggerBody()?['{Identifier}'])}"
                },
                "runAfter": {},
                "type": "ApiConnection"
            },
            "Send_an_email": {
                "inputs": {
                    "body": {
                        "Attachments": [
                            {
                                "ContentBytes": "@{base64(triggerBody()?['{FilenameWithExtension}'])}",
                                "Name": "@{body('Get_file_content')}"
                            }
                        ],
                        "Body": "Hello @{triggerBody()?['FirstName']},</br>\n</br>\nOver the summer, we consulted with you on our new reward offer where you had the opportunity to see your individual package and provide us with your feedback on the proposed offer. \nAs you will have seen in our recent <a href=\"https://ondomain.sharepoint.com/sites/Reward\">OurSpace updates</a> your feedback was invaluable in finalising our final reward offer, which has been approved by the LiveWest Board.</br>\n</br>\nWe are confident that this offer is attractive and competitive, ensuring that we can retain our existing talent and attract new people to our business as we continue to grow.</br>\n</br>\n<h2 style=\"color:#0A1C99;\">Your new reward offer</h2>\nWe are delighted to provide you with your new contract of employment (attached).</br>\n</br>\nFollowing your feedback we will be introducing some of our new terms and conditions in a phased approach. Full of information on the final LiveWest reward offer can be found on OurSpace for more information please click here OurSpace.</br>\n</br>\n</br>\n<h2 style=\"color:#0A1C99;\">Signing your contract</h2>\nPlease electronically sign your contract and return it to our Reward team on <A HREF=\"mailto:rewardteam@livewest.co.uk\">rewardteam@livewest.co.uk</A></br> \n</br>\nIf you do not have this facility available then you can either print it off in one of our offices to sign and scan it to <A HREF=\"mailto:rewardteam@livewest.co.uk\">rewardteam@livewest.co.uk</A> Or if you are not office based please pass the signed copy to your line manager who will then scan and return it to our Reward team on your behalf.</br>\n</br>\n<img src=\"https://ondomain.sharepoint.com/sites/Reward/SiteAssets/Images/electronic-sig.png\" alt=\"Info\" width=\"764\" height=\"242\">\n</br>\n<b>Electronic signature function</b></br>\n</br>\nIdeally, we would like all contracts to be returned signed. However, if you do not return your contract and do not appeal the terms of your contract, we will assume that you are happy with your new terms and conditions and have accepted the final reward offer.</br>\n</br>\n<h2 style=\"color:#0A1C99;\">Appeals</h2>\nIf you wish to appeal your new terms and conditions, you must submit this to the <A HREF=\"mailto:rewardteam@livewest.co.uk\">rewardteam@livewest.co.uk</A> by no later than Friday 29 November 2019, clearly stating the grounds for your appeal.  Our LiveWest Appeals policy can be found on OurSpace.</br>\n</br>\nThank you again for all of your feedback and support throughout harmonisation. We are delighted to now have a strong reward offer in place, which works for you and LiveWest.</br>\n</br>\nIf you have any further queries, please speak to your manager.</br>\n</br>\n</br>\nKind Regards</br>\n</br>\nThe Reward Team",
                        "From": "rewardteam@livewest.co.uk",
                        "IsHtml": true,
                        "Subject": "Private & Confidential - @{body('Get_file_metadata')?['Name']}",
                        "To": "@{triggerBody()?['EmailAddress0']}@{triggerBody()?['EmailAddress2']}"
                    },
                    "host": {
                        "connection": {
                            "name": "@parameters('$connections')['office365']['connectionId']"
                        }
                    },
                    "method": "post",
                    "path": "/Mail"
                },
                "runAfter": {
                    "Get_file_content": [
                        "Succeeded"
                    ]
                },
                "type": "ApiConnection"
            }
        },
        "contentVersion": "1.0.0.0",
        "outputs": {},
        "parameters": {
            "$connections": {
                "defaultValue": {},
                "type": "Object"
            }
        },
        "triggers": {
            "When_a_file_is_created_or_modified_(properties_only)": {
                "inputs": {
                    "host": {
                        "connection": {
                            "name": "@parameters('$connections')['sharepointonline']['connectionId']"
                        }
                    },
                    "method": "get",
                    "path": "/datasets/@{encodeURIComponent(encodeURIComponent('https://ondomain.sharepoint.com/sites/Reward'))}/tables/@{encodeURIComponent(encodeURIComponent('5bb8213b-67e4-464e-b9ff-7e07298b6659'))}/onupdatedfileitems"
                },
                "recurrence": {
                    "frequency": "Minute",
                    "interval": 3
                },
                "splitOn": "@triggerBody()?['value']",
                "type": "ApiConnection"
            }
        }
    }
}



AttachmentEmailSettings.pngAttachmentIssue.pngGetFileMetadata.png

1 ACCEPTED SOLUTION

Accepted Solutions
Community Support Team
Community Support Team

Re: Flow PDF not attaching correctly.

 

Hi @sudosaurus ,

 

Please try this:

 "Attachments": [
                {
                    "Name": "@triggerBody()?['{FilenameWithExtension}']",
                    "ContentBytes": "@{base64(body('Get_file_content'))}"
                }
            ]

It seems that you have placed the file name and file content in the opposite position.

 

Best Regards,

Community Support Team _ Barry
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

2 REPLIES 2
Community Support Team
Community Support Team

Re: Flow PDF not attaching correctly.

 

Hi @sudosaurus ,

 

Please try this:

 "Attachments": [
                {
                    "Name": "@triggerBody()?['{FilenameWithExtension}']",
                    "ContentBytes": "@{base64(body('Get_file_content'))}"
                }
            ]

It seems that you have placed the file name and file content in the opposite position.

 

Best Regards,

Community Support Team _ Barry
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

sudosaurus
Level: Powered On

Re: Flow PDF not attaching correctly.

Thanks for that - not sure how I missed that! 🙂

Helpful resources

Announcements
thirdimage

Power Automate Community User Group Member Badge

Fill out a quick form to claim your user group badge now!

firstImage

Incoming: New and improved badges!

We've given our badges an overhaul and also added some brand new ones!

fifthimage

Microsoft Learn

Learn how to build the business apps that you need.

sixthImage

Power Platform World Tour

Find out where you can attend!

seventhimage

Webinars & Video Gallery

Watch & learn from the Power Automate Community Video Gallery!

Top Kudoed Authors (Last 30 Days)
Users online (6,631)