Expand my Community achievements bar.

Enhance your AEM Assets & Boost Your Development: [AEM Gems | June 19, 2024] Improving the Developer Experience with New APIs and Events

Communications document generation - with URL

Avatar

Level 3

Trying to generate PDF using "Communications document generation" API. Doc URL - https://adobedocs.github.io/experience-manager-forms-cloud-service-developer-reference/api/sync/#tag...

 

Sample code suggest we can use URL. When I tried with my xdp on Azure blob with readonly public access and content type as plain text then PDF generation fails with "Error 400 The specified template is not valid. Specify a valid template and retry." 

 

// You can also pass a URL for the template and set the content type to text/plain
		  		builder.addTextBody("template", "https://forms.enablementadobe.com/content/ocrfiles/address.xdp",ContentType.TEXT_PLAIN);

 

 Any clue? why?

5 Replies

Avatar

Employee Advisor

Can you check if you are able to generate document by passing the template residing on your local file system as shown in the sample code?

Avatar

Level 3

Sample code using local files working. But not using URL as described in the code and documentation.

 

Thanks

Avatar

Level 3

Tried this

			builder.addBinaryBody("data", files[i]);
			// You can also pass a URL for the template and set the content type to
			// text/plain
			builder.addTextBody("template", "https://forms.enablementadobe.com/content/dam/xdptemplates/custom_fonts.xdp", ContentType.TEXT_PLAIN);
			builder.addBinaryBody("options", GetOptions.getPDFOptions().getBytes(), ContentType.APPLICATION_JSON,
					"options");

But failed with error

 

<html>
<head>
<meta http-equiv="Content-Type" content="text/html;charset=ISO-8859-1"/>
<title>Error 400 The specified template is not valid. Specify a valid template and retry.</title>
</head>
<body><h2>HTTP ERROR 400 The specified template is not valid. Specify a valid template and retry.</h2>
<table>
<tr><th>URI:</th><td>/adobe/forms/doc/v1/generatePDFOutput</td></tr>
<tr><th>STATUS:</th><td>400</td></tr>
<tr><th>MESSAGE:</th><td>The specified template is not valid. Specify a valid template and retry.</td></tr>
<tr><th>SERVLET:</th><td>org.apache.felix.http.base.internal.dispatch.DispatcherServlet-2143fb02</td></tr>
</table>

</body>
</html>

 

Thanks

Working if I specify content type like below. However, same is not working if i pass json as data. Bit weird.

		URL xmlUrl = new URL("https://<hostname>/DataFile.xml");
		builder.addBinaryBody("data", xmlUrl.openStream(), ContentType.DEFAULT_BINARY, "data.xml");
		URL xdpUrl = new URL("https://<host>/XSDBasedForm.xdp");
		builder.addBinaryBody("template", xdpUrl.openStream(), ContentType.DEFAULT_BINARY, "test.xdp");