function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Norm CopelandNorm Copeland 

How to pass String collection of URLs to apex action and add to list

Hi, I've only dabbled in Apex in the past but am keen to get a better understanding. I'm building a flow that I would like to have pass a collection of strings (which happen to be URLs to PDFs) to an an Apex action.

In that Apex action I want to send the list of URLs off to an api called API2PDF in order to merge the PDFs. I then need to send the resulting PDF back to the flow.

API2PDF provides the following Apex as an example:
 
String[] urls = new List<String>();
urls.add('http://www.orimi.com/pdf-test.pdf');
urls.add('http://www.orimi.com/pdf-test.pdf');
Api2PdfResponse pdfResponse = a2pClient.mergePdf(urls, true, 'test.pdf');
String pdfUrl = pdfResponse.getPdf();

I've been struggling to put together an invocable apex class that will take a collection of strings (URLS) that will then get added to the apex list urls which is passed to AP2PDF and returns the URL of the merged PDF.

Would anyone be able to give me some direction putting together the apex class? It's a bit beyond me at this point but I know I'll learn a lot picking apart some functioning code. Thank you!

 
Norm CopelandNorm Copeland
I think I'm getting closer but could still use help if anyone is able. 

I currently have:
 
global class mergeAckPDFs {
   @InvocableMethod(label='Submit PDFs for Merging' description='Submits string of PDF Urls to API2PDF and returns a URL of the merged PDFs.')
   public static List<String> getURLs(List<List<String>> URLs) {
        Api2PdfClient a2pClient = new Api2PdfClient('xxxxxxxxxxxxxxxx');
        Api2PdfResponse pdfResponse = a2pClient.mergePdf(URLs, true, 'test.pdf');
        String pdfUrl = pdfResponse.getPdf();
        System.Debug(PdfUrl);
        return pdfURL;
   }
}

But I'm getting the following errors:
  • force-app/main/default/classes/mergeAckPDFs.cls Method does not exist or incorrect signature: void mergePdf(List<List<String>>, Boolean, String) from the type Api2PdfClient (5:49)
  • force-app/main/default/classes/mergeAckPDFs.cls Illegal conversion from String to List<String> (8:9)
Thanks in advance!