Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Merge PDF email attachments with Merge PDF API in logic apps

Explorer ,
May 27, 2024 May 27, 2024

I have a Logic App that monitors incoming emails.  Some have multiple PDF attachments that I want to merge and save to Dropbox.  I have it working with the Encodian API but I want to switch it over to the Adobe API.Screenshot 2024-05-27 165751.png

I then use the array as input for the Encodian API.  When I try this with the Adobe API, I get an error, 

"bad value for parameter 'files'; invalid type".  Doing some reasearch I read somewhere that I should change the fileName line to 

 

"$content-type": "application/pdf"

 

This still returns the same error.  

Even though the files were already PDF's I thought maybe they still needed to be converted to Base64 so I tried that.

Screenshot 2024-05-27 171149.png

 

The Append array action generates this result: 

 

[
	{
		"$content-type":"application/pdf",
		"fileContent":"SlZCRVJ..."
	},
	{
		"$content-type":"application/pdf",
		"fileContent":"SlZCRVJ..."
	}
]

 

The error again is:

 

"bad value for parameter 'files'; invalid type".

 

 the full code for the action is:

 

{
    "inputs": {
        "host": {
            "connection": {
                "name": "@parameters('$connections')['adobepdftools']['connectionId']"
            }
        },
        "method": "post",
        "body": {
            "files": "@variables('FileToMerge')",
            "outputFileName": "Temp.pdf"
        },
        "headers": {
            "x-api-key": "PowerAutomate",
            "x-region-value": "-ue1"
        },
        "path": "/operation/v1/combinePDF"
    }
}

 

 

Why does this have to be so difficult?  Where am I going wrong? 

TOPICS
How to , PDF Embed API , PDF Services API , Power Automate
3.3K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Explorer , May 30, 2024 May 30, 2024

For anyone looking for the same answer, I was finally able to get this sorted out. 

 

If you are using the 'When a new email arrives' trigger, you need to append to the array variable (mine is named 'FilesToMerge' ) using a 'For each' loop based on the trigger body output:

 

triggerBody()?['attachments']

 

 

Then append the contentBytes alone to the array: 

 

 items('For_each')?['contentBytes']

 

 

The json in the code view will look like this:

 

{
    "inputs": {
        "name": "FilesToMerge",
        "valu
...
Translate
Community Beginner ,
Jun 03, 2025 Jun 03, 2025

Alright, I solved it; it's not explicitly mentioned in any of the Adobe blog posts or instructions, but the array has to include content type and content in the schema. Here's what my functional Append to Array step looks like:

{
"$content-type": "application/pdf",
"$content": @{items('For_each')?['contentBytes']}
}

taylor_0370_0-1748965355529.png

taylor_0370_1-1748965540074.png

 

Now I just need to add some renaming steps for loading these to Sharepoint, and a condition check to ensure the flow only runs for multiple files. Thanks for putting a second set of eyes on this, it's like pulling teeth trying to get a useful response from Adobe staff.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Jun 03, 2025 Jun 03, 2025
LATEST

I'm glad you sorted it.  I know what it is like trying to figure all this out.  I am flubbing my way through this stuff just like you. Well done!

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources