Copy link to clipboard
Copied
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.
I then use the array as input for the Encodian API. When I try this with the Adobe API, I get an error,
"$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.
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?
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
...
Copy link to clipboard
Copied
You showed how you created the array, but not how you are calling the API. Are you using the official Acrobat Services connector?
Copy link to clipboard
Copied
Yes, I am using the official connector, thank you, I should have said that. The code for the action is the last block of code in my question.
Copy link to clipboard
Copied
I don't use the code view often for PA, can you share a screenshot of the UI of the action?
Copy link to clipboard
Copied
Copy link to clipboard
Copied
From what I can see, the expection is that the array input is an array of files. You are using an array of objects containing a content-type and fileContent, but I believe it needs to be raw binary.
Copy link to clipboard
Copied
The trigger is the Office 365 Outlook - When a new email arrives (V3)
What output from the trigger do I need to use and how should the append to array be formated? or the Adobe Merge be constructed?
Copy link to clipboard
Copied
Well you need to iterate over the attachments, and get the binary data for each, and append to the array.
Copy link to clipboard
Copied
As far as I know, that's what I am doing. What output from the trigger contains binary data and how is that supposed to be added to the array so that it is not an object?
Copy link to clipboard
Copied
Eh.... I don't know. I'd have to look at your Logic App - that may be something you need to bring up on Microsoft's support forums.
Copy link to clipboard
Copied
I have to wonder if employees who are monitoring a forum for a product such as you are, are trained to be vague and to provide as little help as possible? The fact that I am on forum asking questions indicates that I am looking for help. From my questions you should have realized that I was not understanding something about raw binary vs Base64. You know full well that PDF data bought into a flow is in Base64 format and that it needs to be converted to Binary. I just figured that out myself but you could have been helpful and saved me hours of frustration. You should be ashamed of yourself Raymond.
Now that I have figured out that I need to, and how to, convert the data to Binary, you still haven't provided me with information on the proper formating of the array that I will use as input for the Merge PDF.
Raymond, if you can't provide a helpful answer then I will have to report you to your supervisor.
Copy link to clipboard
Copied
Hi, first off, I'm sorr you feel I'm being vague, it is not my intent. What I was trying to say is that I don't have access to, or my own example, of a flow getting email attachments. I was vague because that portion is outside our pervue and we can't really support that. You said I should have known it came in via Base64. No, I don't know how the email trigger for PowerAutomate supports attachments. I don't know everything about that service that is run by Microsoft. I also stated earlier that you needed the *binary* data. I just couldn't tell you _how_ to do that without knowing what your input is.
Now, I'm glad you got that part working, you said: "you still haven't provided me with information on the proper formating of the array that I will use as input for the Merge PDF", per my earlier message:
"From what I can see, the expection is that the array input is an array of files. You are using an array of objects containing a content-type and fileContent, but I believe it needs to be raw binary."
That is how you create the array. For each set of binary data for each attachment, you append it to the array. There isn't a 'shape', it's just an array of binary blogs essentially.
"Raymond, if you can't provide a helpful answer then I will have to report you to your supervisor." Ok!
Copy link to clipboard
Copied
I understand that I need to append the binary to the array, but is it just the binary? Does it need to be formatted as json or a key/value combination? Is there a content type key value that needs to be included? If you know how the data needs to be recieved by the Merge PDF in array format, you could be more specific on the structure required, perhaps showing an example.
Copy link to clipboard
Copied
Man, I don't know how else to say it. Just. An. Array. Of. Binary. It isn't JSON, there are no keys. So in PowerAutomate, you initialize a new array variable. As you loop over the attachments, I believe PA has an 'append to array' action, and you would pass the binary data to the array. That should literally be it.
Copy link to clipboard
Copied
It won't save the flow because it says invalid JSON.
Copy link to clipboard
Copied
Hmpth, PowerAutomate can be a pain sometimes. Does it specifically say what step has invalid JSON? Also, would you be able to share the flow with raycamde@adobe.com, and then I can take a look?
Copy link to clipboard
Copied
Sorry, got it to save.
Copy link to clipboard
Copied
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 veiw the output of the Array variable with a compose Action, You see a sincle line of code like this:
["---Code from first attachment---","---Second---","---etc---"]
The Adobe Merge PDFs action then will look like this:
Be sure to click this button to change the input mode first:
You can then use the output from the Merge PDFs as the content for whatever action you use to create the new file.
I really hope this is of benefit to someone else searching for the same answer.
Copy link to clipboard
Copied
Very happy you got it, and thank you for sharing your solution!
Copy link to clipboard
Copied
I have a virtually identical flow to yours, including a compose step for debugging, but I'm receiving the same error you encountered. I've verified that I'm using the "array" view in the Merge step, but nothing I do seems to work.
The only thing I can think of is that the code view for my "Append to Array Variable" step also includes some metadata in the JSON automatically, but this isn't something that can be changed as it's auto-generated by Microsoft (see image)
Here's the non-code view:
When I check the ouput of "Append to Array" using a "Compose" step ouside of the loop, it looks just like what you've posted. I've also verified that the JSON code view of the "Merge PDF" step is accurate.
This seems like such a simple task, but I'm driving myself up the wall trying to debug this. Is there anything obvious you can see in my flow that might be causing me to still get the same error you did?
Copy link to clipboard
Copied
The first thing I notice is that your file content is not a PDF, a pdf's base64 will start with JVBER. At least in all of my work. If the file is not a PDF then you need to convert it to a PDF first.
Copy link to clipboard
Copied
The Base64 bytes of the files I'm passing aren't visible in any of these image; they're just code view of the flow steps. I've verified in my tests that I'm using PDFs, and there's a conditional step displayed in one of the images to verify that only pdf attachements are passed to the array.
Copy link to clipboard
Copied
To clarify, here's the input view for the Adobe Merge step that's failing; I've verified via a "compose" step and by manually reviewing the output of "Append to Array" that both file objects are in fact valid PDFs.
and the second file (for obvious reasons I've truncated the full view of the input)
When I check the output of both the "compose" and "append to array" steps from a failed run, they appear to match the structure in your working example (the below images are truncated for clarity)
I'm wondering if something about the "Append" step is missing the final "==" intended for signaling "end of file" now that I look at it.
Copy link to clipboard
Copied
In base64 the string must be divisible by 4 from what I understand, and the == at the end are used to fill in emply spaces to make it the correct length.
Copy link to clipboard
Copied
Right, i did see that. then as I was looking back at nmy own question I saw the wrong base64. My bad.
I have been having some issues with item()?['contentBytes'] at times. sometime you include the name of the for each and other times you don't. but this is what I have found:
I have been using ChatGPT to help me out and it has been quite useful.
I would try removing the For_each reference in your Append to array variable.
Find more inspiration, events, and resources on the new Adobe Community
Explore Now