Make multiple POST calls to target endpoint from single inbound request

Hi all - I’m working on a proxy that receives electronically signed documents from DocuSign and uploads them to our storage system. The inbound request is in XML format and contains some metadata plus the actual PDF bytes as base-64 encoded strings. I’m extracting the data I need, encoding it as multipart/form-data and making a POST request against the target endpoint. This is working great for a single document, but sometimes, the inbound request from DocuSign contains multiple documents. For example:

	<DocumentPDFs>
		<DocumentPDF>
			<Name>SampleDoc01.pdf</Name>
			<PDFBytes>ZHVtbXkgUERGIGZpbGUgYnl0ZXM=...</PDFBytes>
			<DocumentID>1</DocumentID>
		</DocumentPDF>
		<DocumentPDF>
			<Name>SampleDoc02.pdf</Name>
			<PDFBytes>ZHVtbXkgUERGIGZpbGUgYnl0ZXM=...</PDFBytes>
			<DocumentID>2</DocumentID>
		</DocumentPDF>
	</DocumentPDFs>

I’m struggling to find a solution that allows me to iterate over each and make a separate POST request against the target endpoint for each file. Wondering if anyone has designed something similar or has thoughts on the best approach? Thanks!

1 Like