Skip to main content
Participant
November 4, 2021
Question

Merge PDFs in Logic app returns "The underlying connection was closed: An unexpected error occurred

  • November 4, 2021
  • 1 reply
  • 1759 views

Hi,

I have created a Logic App in Azure that collects PDFs in a array and will use "Merge PDFs"-action:

Below is some of the input that is sent to the "Merge PDFs"-action:

"body": {
		"files": [
			{
				"$content": "JVBERi0xLjYNJeLjz9MNCjMxMyAwIG9iag08PC9MaW5lYXJpemVkIDEvTCAxNzQwMzMvTyAzMTUvRSAxNTk1MDMvTiAyL1QgMTczNjY3L0ggWyA1MjMgMjM5XT4+DWVuZG9iag0gICAgICAgICAgICA..",
				"$content-type": "application/pdf"
			},
			{
				"$content-type": "application/pdf",
				"$content": "JVBERi0xLjcNCiW1tbW1DQoxIDAgb2JqDQo8PC9UeXBlL0NhdGFsb2cvUGFnZXMgMiAwIFIvTGFuZyhlbi1VUykgL1N0cnVjdFRyZWVSb290IDIzIDAgUi9NYXJrSW5mbzw8L01hcmtlZCB0cnVlPj4.."
			}
		],
		"outputFileName": "Dummy.pdf"
	}

I have also tried to create another logic app that retrieves PDF-content from to SharePoint-files, append them to an array and then run "Merge PDFs". Same error here:


The "Generate document from Word template" and "Convert Word to PDF" works fine:

 

This topic has been closed for replies.

1 reply

Ben Vanderberg
Community Manager
Community Manager
December 21, 2021

Hi @NOSYS5EAC ,

 

I was looking into this and I am finding some interesting parts about the difference between Generate document from Word template and the Merge PDF action.

 

To test, I was using a OneDrive for Business step like this:

 

If you look at the Generate document from Word template and you use Dynamic content to insert the file content from OneDrive, it provides this in the code:

 

However, if you look at the Merge PDF code and you insert the variables, the code looks like this:

 

So basically what that tells me is that the Generate Document step accepts the $content and $content-type object, however Merge PDF is looking for a base64 version of the body.

Participating Frequently
February 1, 2022

 

I am getting the same error on MS PowerAutomate

Participating Frequently
February 11, 2022

I have finally understood what you meant
you have to get the file content, compose it to base64, append to array and then merge the array