Merging multiple documents to PDF using Microsoft Flow getting error "For application/pdf mime-type"

Community Beginner ,
Apr 14, 2021 Apr 14, 2021

Copy link to clipboard

Copied

Hey, My requirement is to merge multiple document into pdf using Microsoft Flow but every time getting error ("For application/pdf mime-type The input file appears to be corrupted and cannot be processed.;...-PowerAutomate").

Below are the step which implemented in my flow with screenshot  : 

  1. Flow trigger. (manually)
  2. Get files (properties only) We start with getting properties of all our DOCX files stored in a specific folder - Source Files Library. ...
  3. Initialize Array variable. ...
  4. Get file content using path. ...
  5. Convert DOCX to PDF. ...
  6. Append to an array variable. ...
  7. Merge PDF. ...

 

MAla5C4D_0-1618402410246.pngMAla5C4D_1-1618402768656.png

MAla5C4D_3-1618402833763.png

 

Full Flow : 

MAla5C4D_2-1618402808619.png

Please let me know how I can merge multiple document into single pdf using Adobe Connector from Microsoft Flow. Currently using the above flow getting error  ("For application/pdf mime-type The input file appears to be corrupted and cannot be processed.;...-PowerAutomate") but the document are not corrupted.

TOPICS
PDF Services API , Power Automate

Views

1.7K

Likes

Translate

Translate

Report

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
Adobe Employee ,
Apr 14, 2021 Apr 14, 2021

Copy link to clipboard

Copied

Have a look at the solution in this thread about creating an object to pass the content type and file content:

https://community.adobe.com/t5/document-services-apis/power-automate-split-and-merge-the-split-outpu...

This is a common in many Power Automate scenarios. 

Likes

Translate

Translate

Report

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
Community Beginner ,
Apr 14, 2021 Apr 14, 2021

Copy link to clipboard

Copied

Thank you so much for the reply. After implementing content type in array still getting the same issue . Below is the screenshot:

 

MAla5C4D_0-1618419225924.png

but still getting the same issue .

MAla5C4D_1-1618419326878.png

 

Please help me on the above issue. Awaiting your response!

Likes

Translate

Translate

Report

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
New Here ,
Apr 18, 2021 Apr 18, 2021

Copy link to clipboard

Copied

Hi,

 

I am having a similar issue when trying to merge seveal documents which i am accessing with the sharepoint "Get file content" card.

 

I have created and array to which i am appending

{
"$content-type": @{body('Get_file_properties_2')?['{ContentType}']?['Name']},
"$content": @{body('Get_file_content')}
}

however i am returning a "Bad Gateway" error on the Adobe "Merge PDF's" card.

 

Im assuming there is some issue with the format that is returned by the sharepoint card not being what is expected by the Adobe card.

Capture.PNG

Capture.PNG

Likes

Translate

Translate

Report

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
Adobe Employee ,
Apr 18, 2021 Apr 18, 2021

Copy link to clipboard

Copied

It looks like you are inserting an array object into an individual item. Click the Button in the image attached to switch to JSON data mode and then clear everything and set your array variable. 

2A2EF7BC-34E2-457B-80B0-BFB57D8C77A4.jpeg

Likes

Translate

Translate

Report

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
New Here ,
Apr 19, 2021 Apr 19, 2021

Copy link to clipboard

Copied

Hi Ben,

 

I am deffinately working with the JSON type editor, as the individual item shows "File 1, File 2, File n, etc."

Additionaly, the "File content" from the Get File Content card returns a 2D array which has 

"$content-type" 
&
"$content"

as its elements.

The array created in the image above "Append to array variable 8" returned, 

{"$content-type":"Document Library","$content":{"$content-type":"application/pdf","$content":"JVBERi0xLj~"}}

 which im assuming is not correct.

 

I have changed the array i am inputting into the "Merge PDF" card (resulting in the below structure), but am still receiving a "Bad Gateway" error.

Can you tell me the syntax expected by the "Merge PDF" card is?

Does it expect

[
{
"$content-type":"application/pdf",
"$content":"JVBERi0~"
}
{
etc.
}
]

 or is there some issue with the syntax of the "$content-type" element ("application.pdf" maybe?)

 

Thankyou for your help!

 

Likes

Translate

Translate

Report

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
Adobe Employee ,
May 18, 2021 May 18, 2021

Copy link to clipboard

Copied

Hi @Thomas5C18 ,

 

I tried to replicate your type of flow locally. It seems to be working on my end. A few things:

  • Absolutely sure that you are passing all PDF documents to Merge PDF action? If not, then you need to convert beforehand. 
  • Make sure your $content-type is application/pdf. If it isn't, Merge PDF will reject it. 
  • You can't just pass the file content into the array because Merge PDF is strict that it will only accept $content-type and $content in the object.

 

Below is an image to help illustrate an example that is working. It seems like it is probably something little like a wrong mime-type or something else. Out of curiosity, check to see if you write the content type static, does it make a difference?

 

2021-05-18_15-54-12.png

2021-05-18_15-46-32.png

  

Likes

Translate

Translate

Report

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
Community Beginner ,
May 24, 2021 May 24, 2021

Copy link to clipboard

Copied

Hi @beni ,

 

Thanks for your response. I have gone through your solution and compared with the steps which I have followed to merge the PDFs. Please find below array outcome which I passed in merge PDF function  which you also suggested. 

 

[{"$content-type":"application/pdf","$content":"JVB............. "},{"$content-type":"application/pdf","$content": "JVB…………… "}]

 

MAla5C4D_1-1621869308136.png

 

but still getting the same error 

 

MAla5C4D_0-1621869017807.png

 

So please suggest if still I am missing something which is causing this error.

 

Thanks 

Mala

Likes

Translate

Translate

Report

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
Community Beginner ,
Apr 14, 2022 Apr 14, 2022

Copy link to clipboard

Copied

Hi Mala,

 

I notice your post and would like to share with you.

 

Have you solve it already?

 

Best regards,

Likar

Likes

Translate

Translate

Report

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
Adobe Employee ,
Jul 20, 2022 Jul 20, 2022

Copy link to clipboard

Copied

LATEST

Do you have a document you might be able to private message? Since I can't recreate the issue, it makes me wonder if there is something with the file.

Likes

Translate

Translate

Report

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