pdfpdf-generationadobe

Problem with the Adobe Merge PDF api in logic apps - bad parameter, invalid type


I have posted this in the Adobe Community also but have not had a reply so I thought I should hit my normal Go-To Community.

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.

enter image description here

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 research 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.

enter image description here

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"
    }
}

Thank you for any insight that can be provided!


Solution

  • 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",
            "value": "@items('For_each')?['contentBytes']"
        }
    }
    

    If you view the output of the Array variable with a compose Action, You see a single line of code like this:

    ["---Code from first attachment---","---Second---","---etc---"] 
    

    The Adobe Merge PDFs action then will look like this:enter image description here

    Be sure to click this button to change the input mode first: enter image description here

    You can then use the output from the Merge PDFs as the content for whatever action you want to use to create the new file.

    I posted this to my same question in the Adobe Forum